Interface SegmentIterator<T>

  • Type Parameters:
    T - The type of the events written to this segment.
    All Superinterfaces:
    java.lang.AutoCloseable, java.util.Iterator<T>

    @Beta
    public interface SegmentIterator<T>
    extends java.util.Iterator<T>, java.lang.AutoCloseable
    Please note this is an experimental API. Allows for reading data from a segment. Returns an item from Iterator.next() for each event in the segment at the time of its creation. Once all the events that were in the segment at the time of the creation of the SegmentIterator have been returned Iterator.hasNext() will return false. While buffering is used to avoid it, it is possible for Iterator.next() to block on fetching the data. While iterating over SegmentIterator using Iterator.next() it can throw TruncatedDataException if SegmentIterator is pointing to an offset which is already truncated. If this exception occurs, SegmentIterator will automatically update headOffset to next available offset. Next call to Iterator.next() will point correctly to valid offset and reader will continue. At any time getOffset() can be called to get the byte offset in the segment the iterator is currently pointing to.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void close()
      Closes the iterator, freeing any resources associated with it.
      long getOffset()
      Provides the current offset in the segment.
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, hasNext, next, remove
    • Method Detail

      • getOffset

        long getOffset()
        Provides the current offset in the segment.
        Returns:
        The current offset in the segment
      • close

        void close()
        Closes the iterator, freeing any resources associated with it.
        Specified by:
        close in interface java.lang.AutoCloseable
        See Also:
        AutoCloseable.close()