AtomixLogStorageReader implements LogStorageReader { @Override public long lookUpApproximateAddress(final long position) { final var low = reader.getFirstIndex(); final var high = reader.getLastIndex(); if (position == Long.MIN_VALUE) { final var optionalEntry = findEntry(reader.getFirstIndex()); return optionalEntry.map(Indexed::index).orElse(LogStorage.OP_RESULT_INVALID_ADDR); } if (low >= high) { if (findEntry(low).isEmpty()) { return LogStorage.OP_RESULT_INVALID_ADDR; } return low; } final var index = zeebeIndexMapping.lookupPosition(position); final long result; if (index == -1) { result = low; } else { result = index; } return result; } AtomixLogStorageReader(
      final ZeebeIndexMapping zeebeIndexMapping, final RaftLogReader reader); @Override boolean isEmpty(); @Override long read(final DirectBuffer readBuffer, final long address); @Override long readLastBlock(final DirectBuffer readBuffer); @Override long lookUpApproximateAddress(final long position); @Override void close(); Optional<Indexed<ZeebeEntry>> findEntry(final long index);  }
@Test public void shouldReturnInvalidOnEmptyLookUp() { final var reader = storageRule.get().newReader(); final var address = reader.lookUpApproximateAddress(1); assertThat(address).isEqualTo(LogStorage.OP_RESULT_INVALID_ADDR); }