Class LogStreamReaderImpl

java.lang.Object
io.camunda.zeebe.logstreams.impl.log.LogStreamReaderImpl
All Implemented Interfaces:
LogStreamReader, CloseableSilently, AutoCloseable, Iterator<LoggedEvent>

public final class LogStreamReaderImpl extends Object implements LogStreamReader
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 Details

  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<LoggedEvent>
    • next

      public LoggedEvent next()
      Specified by:
      next in interface Iterator<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:
      seekToNextEvent in interface LogStreamReader
      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:
      seek in interface LogStreamReader
      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:
      seekToFirstEvent in interface LogStreamReader
    • seekToEnd

      public long seekToEnd()
      Seek to the end of the log, which means after the last event.
      Specified by:
      seekToEnd in interface LogStreamReader
      Returns:
      the position of the last entry
    • getPosition

      public long getPosition()
      Returns the current log position of the reader.
      Specified by:
      getPosition in interface LogStreamReader
      Returns:
      the current log position, or negative value if the log is empty or not initialized
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface CloseableSilently
    • peekNext

      public LoggedEvent peekNext()
      Description copied from interface: LogStreamReader
      Peeks the next event on the log. It is similar to Iterator.next() but it doesn't move the iterator. It should only be called if Iterator.hasNext() returns true.
      Specified by:
      peekNext in interface LogStreamReader
      Returns:
      return the next event on the log