}
@Override
- public void reset(long index) {
+ void reset(long index) {
long nextIndex = firstIndex;
// Clear the buffer indexes.
}
@Override
- public long getLastIndex() {
- return lastEntry != null ? lastEntry.index() : firstIndex - 1;
- }
-
- @Override
- public Indexed<E> getLastEntry() {
+ Indexed<E> getLastEntry() {
return lastEntry;
}
@Override
- public long getNextIndex() {
+ long getNextIndex() {
if (lastEntry != null) {
return lastEntry.index() + 1;
} else {
}
}
- @Override
- public void append(Indexed<E> entry) {
- final long nextIndex = getNextIndex();
-
- // If the entry's index is greater than the next index in the segment, skip some entries.
- if (entry.index() > nextIndex) {
- throw new IndexOutOfBoundsException("Entry index is not sequential");
- }
-
- // If the entry's index is less than the next index, truncate the segment.
- if (entry.index() < nextIndex) {
- truncate(entry.index() - 1);
- }
- append(entry.entry());
- }
-
@Override
@SuppressWarnings("unchecked")
- public <T extends E> Indexed<T> append(T entry) {
+ <T extends E> Indexed<T> append(T entry) {
// Store the entry index.
final long index = getNextIndex();
return (Indexed<T>) indexedEntry;
}
-
@Override
- public void truncate(long index) {
+ void truncate(long index) {
// If the index is greater than or equal to the last index, skip the truncate.
if (index >= getLastIndex()) {
return;
}
@Override
- public void flush() {
+ void flush() {
mappedBuffer.force();
}
@Override
- public void close() {
+ void close() {
flush();
try {
BufferCleaner.freeBuffer(mappedBuffer);