Class LogStreamReaderImpl
java.lang.Object
io.camunda.zeebe.logstreams.impl.log.LogStreamReaderImpl
- All Implemented Interfaces:
LogStreamReader,CloseableSilently,AutoCloseable,Iterator<LoggedEvent>
A
LogStreamReader implementation which can read single events from the blocks given by
the LogStorageReader.
This implementation assumes that blocks have no padding - they contain a contiguous series of
LoggedEvent which fits exactly within the block.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()longReturns the current log position of the reader.booleanhasNext()next()peekNext()Peeks the next event on the log.booleanseek(long position) Seek to the given log position if exists, or the lowest position that is greater than the given one.longSeek to the end of the log, which means after the last event.voidSeek to the log position of the first event.booleanseekToNextEvent(long position) Seeks to the event after the given position.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
LogStreamReaderImpl
-
-
Method Details
-
hasNext
public boolean hasNext()- Specified by:
hasNextin interfaceIterator<LoggedEvent>
-
next
- Specified by:
nextin interfaceIterator<LoggedEvent>
-
seekToNextEvent
public boolean seekToNextEvent(long position) Seeks to the event after the given position.On negative position it seeks to the first event.
- Specified by:
seekToNextEventin interfaceLogStreamReader- Parameters:
position- the position which should be used- Returns:
true, if the position is negative or exists
-
seek
public boolean seek(long position) Seek to the given log position if exists, or the lowest position that is greater than the given one.- Specified by:
seekin interfaceLogStreamReader- Parameters:
position- the position in the log to seek to- Returns:
true, if the given position exists.
-
seekToFirstEvent
public void seekToFirstEvent()Seek to the log position of the first event.- Specified by:
seekToFirstEventin interfaceLogStreamReader
-
seekToEnd
public long seekToEnd()Seek to the end of the log, which means after the last event.- Specified by:
seekToEndin interfaceLogStreamReader- Returns:
- the position of the last entry
-
getPosition
public long getPosition()Returns the current log position of the reader.- Specified by:
getPositionin interfaceLogStreamReader- Returns:
- the current log position, or negative value if the log is empty or not initialized
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseableSilently
-
peekNext
Description copied from interface:LogStreamReaderPeeks the next event on the log. It is similar toIterator.next()but it doesn't move the iterator. It should only be called ifIterator.hasNext()returnstrue.- Specified by:
peekNextin interfaceLogStreamReader- Returns:
- return the next event on the log
-