*/
@NonNullByDefault
public interface ByteBufJournal extends AutoCloseable {
+ /**
+ * Return the index of the first entry in the journal.
+ *
+ * @return the index of the first entry in the journal
+ */
+ long firstIndex();
+
/**
* Return the index of the last entry in the journal.
*
- * @return the last index, or zero if there are no entries.
+ * @return the last index, or zero if there are no entries
*/
long lastIndex();
T mapEntry(long index, ByteBuf bytes);
}
- /**
- * Returns the first index in the journal.
- *
- * @return The first index in the journal
- */
- long firstIndex();
-
/**
* Returns the next reader index.
*
* @author <a href="http://github.com/kuujo">Jordan Halterman</a>
*/
public interface Journal<E> extends AutoCloseable {
+ /**
+ * Return the index of the first entry in the journal.
+ *
+ * @return the index of the first entry in the journal
+ */
+ long firstIndex();
+
/**
* Return the index of the last entry in the journal.
*
T mapEntry(long index, E entry, int size);
}
- /**
- * Returns the first index in the journal.
- *
- * @return the first index in the journal
- */
- long getFirstIndex();
-
/**
* Returns the next reader index.
*
.sum();
}
+ @Override
+ public long firstIndex() {
+ return firstSegment().firstIndex();
+ }
+
@Override
public long lastIndex() {
return lastSegment().lastIndex();
nextIndex = currentSegment.firstIndex();
}
- @Override
- public final long firstIndex() {
- return journal.firstSegment().firstIndex();
- }
-
@Override
public final long nextIndex() {
return nextIndex;
writer = new SegmentedJournalWriter<>(journal.writer(), mapper);
}
+ @Override
+ public long firstIndex() {
+ return journal.firstIndex();
+ }
+
@Override
public long lastIndex() {
return journal.lastIndex();
this.mapper = requireNonNull(mapper);
}
- @Override
- public long getFirstIndex() {
- return reader.firstIndex();
- }
-
@Override
public long getNextIndex() {
return reader.nextIndex();
// Ensure the reader starts at the first physical index in the journal.
assertEquals(entriesPerSegment + 1, reader.getNextIndex());
- assertEquals(reader.getFirstIndex(), reader.getNextIndex());
+ assertEquals(journal.firstIndex(), reader.getNextIndex());
assertEquals(entriesPerSegment + 1, assertNext(reader).index());
assertEquals(entriesPerSegment + 2, reader.getNextIndex());
}