@Override public boolean hasNext() { switch (state) { case EMPTY_LOG_STREAM: seekToFirstEvent(); break; case NOT_ENOUGH_DATA: readNextAddress(); break; case EVENT_NOT_COMMITTED: checkIfNextEventIsCommitted(); break; case WRAP_NOT_CALLED: throw new IllegalStateException("Iterator not initialized"); } return state == IteratorState.EVENT_AVAILABLE; }
@Override public boolean hasNext() { switch (state) { case EMPTY_LOG_STREAM: seekToFirstEvent(); break; case NOT_ENOUGH_DATA: readNextAddress(); break; case EVENT_NOT_COMMITTED: checkIfNextEventIsCommitted(); break; case WRAP_NOT_CALLED: throw new IllegalStateException("Iterator not initialized"); } return state == IteratorState.EVENT_AVAILABLE; }
private void readNextEvent() { // initially we assume there is not enough data state = IteratorState.NOT_ENOUGH_DATA; final int remaining = byteBuffer.position() - bufferOffset; if (remaining > 0) { wrapNextEvent(bufferOffset); bufferOffset += nextEvent.getFragmentLength(); checkIfNextEventIsCommitted(); } else { readNextAddress(); } }
private void readNextEvent() { // initially we assume there is not enough data state = IteratorState.NOT_ENOUGH_DATA; final int remaining = byteBuffer.position() - bufferOffset; if (remaining > 0) { wrapNextEvent(bufferOffset); bufferOffset += nextEvent.getFragmentLength(); checkIfNextEventIsCommitted(); } else { readNextAddress(); } }
private boolean searchPositionInBuffer(final long position) { while (isNextUncommittedEventAvailable() && nextEvent.getPosition() < position) { readNextEvent(); } if (nextEvent.getPosition() < position) { // not in buffered block, read next block and continue the search return readNextAddress() && searchPositionInBuffer(position); } return nextEvent.getPosition() == position; }
private boolean searchPositionInBuffer(final long position) { while (isNextUncommittedEventAvailable() && nextEvent.getPosition() < position) { readNextEvent(); } if (nextEvent.getPosition() < position) { // not in buffered block, read next block and continue the search return readNextAddress() && searchPositionInBuffer(position); } return nextEvent.getPosition() == position; }