@Test public void placesAnUpperBoundOnTheNumberOfEntriesItSkipsPastWhenComputingEntriesAddresses() throws Exception { for (int i = LAST_SEQ_NUM; i >= 1; i--) { final long seqNum = (long) i; int numberOfSkipOperations = numberOfSkipOperations(() -> navigator.getAddressOfEntry(seqNum)); assertThat(numberOfSkipOperations, is(lessThanOrEqualTo(MAX_SEEK))); } }
@Override public long getAddressOfEntry(long seqNum) throws IOException, LogEntryNotFound { if (index.containsKey(seqNum)) { return index.get(seqNum); } else { try (PersistenceReader reader = getReaderAtSeqNum(seqNum)) { return reader.position(); } } }
InMemoryPersistenceNavigator implements PersistenceNavigator { @Override public long getAddressOfEntry(long seqNum) throws IOException, LogEntryNotFound { if (index.containsKey(seqNum)) { return index.get(seqNum); } else { try (PersistenceReader reader = getReaderAtSeqNum(seqNum)) { return reader.position(); } } } }
InMemoryPersistenceNavigator implements PersistenceNavigator { @Override public long getAddressOfEntry(long seqNum) throws IOException, LogEntryNotFound { if (index.containsKey(seqNum)) { return index.get(seqNum); } else { try (PersistenceReader reader = getReaderAtSeqNum(seqNum)) { return reader.position(); } } } InMemoryPersistenceNavigator(BytePersistence persistence, SequentialEntryCodec<E> codec);  InMemoryPersistenceNavigator(BytePersistence persistence, SequentialEntryCodec<E> codec, long offset); }
InMemoryPersistenceNavigator implements PersistenceNavigator { @Override public long getAddressOfEntry(long seqNum) throws IOException, LogEntryNotFound { if (index.containsKey(seqNum)) { return index.get(seqNum); } else { try (PersistenceReader reader = getReaderAtSeqNum(seqNum)) { return reader.position(); } } } InMemoryPersistenceNavigator(BytePersistence persistence, SequentialEntryCodec<E> codec);  InMemoryPersistenceNavigator(BytePersistence persistence, SequentialEntryCodec<E> codec, long offset); void setMaxEntrySeek(int numberOfEntries); @Override void notifyLogging(long seqNum, long byteAddress); @Override void addToIndex(long seqNum, long address); @Override void notifyTruncation(long seqNum); @Override long getAddressOfEntry(long seqNum); @Override InputStream getStreamAtSeqNum(long seqNum); @Override InputStream getStreamAtFirstEntry(); @Override InputStream getStreamAtLastEntry(); }
InMemoryPersistenceNavigator implements PersistenceNavigator { @Override public long getAddressOfEntry(long seqNum) throws IOException, LogEntryNotFound { if (index.containsKey(seqNum)) { return index.get(seqNum); } else { try (PersistenceReader reader = getReaderAtSeqNum(seqNum)) { return reader.position(); } } } InMemoryPersistenceNavigator(BytePersistence persistence, SequentialEntryCodec<E> codec);  InMemoryPersistenceNavigator(BytePersistence persistence, SequentialEntryCodec<E> codec, long offset); void setMaxEntrySeek(int numberOfEntries); @Override void notifyLogging(long seqNum, long byteAddress); @Override void addToIndex(long seqNum, long address); @Override void notifyTruncation(long seqNum); @Override long getAddressOfEntry(long seqNum); @Override InputStream getStreamAtSeqNum(long seqNum); @Override InputStream getStreamAtFirstEntry(); @Override InputStream getStreamAtLastEntry();  }