Package io.pravega.client.batch
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 fromIterator.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 returnedIterator.hasNext()
will return false. While buffering is used to avoid it, it is possible forIterator.next()
to block on fetching the data. While iterating over SegmentIterator usingIterator.next()
it can throwTruncatedDataException
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 toIterator.next()
will point correctly to valid offset and reader will continue. At any timegetOffset()
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.
-