E
- The type of the record returned by the iterator.@PublicEvolving public final class ArrayResultIterator<E> extends RecyclableIterator<E> implements BulkFormat.RecordIterator<E>
BulkFormat.RecordIterator
that returns the elements of an array, one after the
other. The iterator is mutable to support object reuse and supports recycling.Constructor and Description |
---|
ArrayResultIterator()
Creates a new, initially empty,
ArrayResultIterator . |
ArrayResultIterator(Runnable recycler)
Creates a new, initially empty,
ArrayResultIterator . |
Modifier and Type | Method and Description |
---|---|
RecordAndPosition<E> |
next()
Gets the next record from the file, together with its position.
|
void |
set(E[] records,
int num,
long offset,
long skipCountOfFirst)
Sets the records to be returned by this iterator.
|
releaseBatch
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
releaseBatch
public ArrayResultIterator()
ArrayResultIterator
.public ArrayResultIterator(@Nullable Runnable recycler)
ArrayResultIterator
. The iterator calls the given
recycler
when the RecyclableIterator.releaseBatch()
method is called.public void set(E[] records, int num, long offset, long skipCountOfFirst)
RecordAndPosition
will have the same offset (for RecordAndPosition.getOffset()
. The first returned
record will have a records-to-skip count of skipCountOfFirst + 1
, following the
contract that each record needs to point to the position AFTER itself (because a checkpoint
taken after the record was emitted needs to resume from after that record).@Nullable public RecordAndPosition<E> next()
BulkFormat.RecordIterator
The position information returned with the record point to the record AFTER the returned record, because it defines the point where the reading should resume once the current record is emitted. The position information is put in the source's state when the record is emitted. If a checkpoint is taken directly after the record is emitted, the checkpoint must to describe where to resume the source reading from after that record.
Objects returned by this method may be reused by the iterator. By the time that this
method is called again, no object returned from the previous call will be referenced any
more. That makes it possible to have a single MutableRecordAndPosition
object and
return the same instance (with updated record and position) on every call.
next
in interface BulkFormat.RecordIterator<E>
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.