@Test public void readsEntriesFromTheSuppliedPersistenceObjectUsingTheSuppliedCodec() throws Exception { long startSeqNum = 77; long endSeqNum = 83; context.checking(new Expectations() {{ codecWillReturnEntrySequence(codec, someConsecutiveEntries(startSeqNum, endSeqNum)); allowing(persistence).getReader(); allowing(navigator).getStreamAtSeqNum(startSeqNum); will(returnValue(aMockInputStream())); }}); log.subSequence(startSeqNum, endSeqNum); }
@Override public List<E> subSequence(long start, long end) throws IOException, LogEntryNotFound, LogEntryNotInSequence { final List<E> readEntries = new ArrayList<>(); try (InputStream reader = persistenceNavigator.getStreamAtSeqNum(start)) { long seqNum; do { E entry = codec.decode(reader); readEntries.add(entry); seqNum = entry.getSeqNum(); } while (seqNum < end - 1); } catch (EOFException e) { throw new LogEntryNotFound("EOF reached before finding all requested entries: seqNum range [" + start + ", " + end + ")"); } ensureAscendingWithNoGaps(readEntries); return readEntries; }
EncodedSequentialLog implements SequentialLog<E> { @Override public List<E> subSequence(long start, long end) throws IOException, LogEntryNotFound, LogEntryNotInSequence { final List<E> readEntries = new ArrayList<>(); try (InputStream reader = persistenceNavigator.getStreamAtSeqNum(start)) { long seqNum; do { E entry = codec.decode(reader); readEntries.add(entry); seqNum = entry.getSeqNum(); } while (seqNum < end - 1); } catch (EOFException e) { throw new LogEntryNotFound("EOF reached before finding all requested entries: seqNum range [" + start + ", " + end + ")"); } ensureAscendingWithNoGaps(readEntries); return readEntries; } }
EncodedSequentialLog implements SequentialLog<E> { @Override public List<E> subSequence(long start, long end) throws IOException, LogEntryNotFound, LogEntryNotInSequence { final List<E> readEntries = new ArrayList<>(); try (InputStream reader = persistenceNavigator.getStreamAtSeqNum(start)) { long seqNum; do { E entry = codec.decode(reader); readEntries.add(entry); seqNum = entry.getSeqNum(); } while (seqNum < end - 1); } catch (EOFException e) { throw new LogEntryNotFound("EOF reached before finding all requested entries: seqNum range [" + start + ", " + end + ")"); } ensureAscendingWithNoGaps(readEntries); return readEntries; } EncodedSequentialLog(BytePersistence persistence,
                              SequentialEntryCodec<E> codec,
                              PersistenceNavigator persistenceNavigator); }
EncodedSequentialLog implements SequentialLog<E> { @Override public List<E> subSequence(long start, long end) throws IOException, LogEntryNotFound, LogEntryNotInSequence { final List<E> readEntries = new ArrayList<>(); try (InputStream reader = persistenceNavigator.getStreamAtSeqNum(start)) { long seqNum; do { E entry = codec.decode(reader); readEntries.add(entry); seqNum = entry.getSeqNum(); } while (seqNum < end - 1); } catch (EOFException e) { throw new LogEntryNotFound("EOF reached before finding all requested entries: seqNum range [" + start + ", " + end + ")"); } ensureAscendingWithNoGaps(readEntries); return readEntries; } EncodedSequentialLog(BytePersistence persistence,
                              SequentialEntryCodec<E> codec,
                              PersistenceNavigator persistenceNavigator); @Override void append(List<E> entries); @Override List<E> subSequence(long start, long end); @Override boolean isEmpty(); @Override E getLastEntry(); @Override SequentialEntryIterator<E> iterator(); @Override void truncate(long seqNum); @Override void sync(); @Override void close(); }
EncodedSequentialLog implements SequentialLog<E> { @Override public List<E> subSequence(long start, long end) throws IOException, LogEntryNotFound, LogEntryNotInSequence { final List<E> readEntries = new ArrayList<>(); try (InputStream reader = persistenceNavigator.getStreamAtSeqNum(start)) { long seqNum; do { E entry = codec.decode(reader); readEntries.add(entry); seqNum = entry.getSeqNum(); } while (seqNum < end - 1); } catch (EOFException e) { throw new LogEntryNotFound("EOF reached before finding all requested entries: seqNum range [" + start + ", " + end + ")"); } ensureAscendingWithNoGaps(readEntries); return readEntries; } EncodedSequentialLog(BytePersistence persistence,
                              SequentialEntryCodec<E> codec,
                              PersistenceNavigator persistenceNavigator); @Override void append(List<E> entries); @Override List<E> subSequence(long start, long end); @Override boolean isEmpty(); @Override E getLastEntry(); @Override SequentialEntryIterator<E> iterator(); @Override void truncate(long seqNum); @Override void sync(); @Override void close();  }