public class AsyncOperationBatchIterator extends java.lang.Object implements BatchIterator
BatchAccumulator
.
Every BatchAccumulator.batchSize()
items, BatchAccumulator.processBatch(boolean)
is used
to create the data for *this* BatchIterator.
(encapsulated via loadNextBatch()
)
+-> source data
| |
| batchAccumulator.onItem
| |
| batchSize reached?
| |
+----------+---+
|
batchAccumulator.processBatch
onResult -> fill-up data of *this* BatchIterator
Constructor and Description |
---|
AsyncOperationBatchIterator(BatchIterator source,
int numColumns,
BatchAccumulator<Row,java.util.Iterator<? extends Row>> batchAccumulator) |
Modifier and Type | Method and Description |
---|---|
boolean |
allLoaded() |
void |
close()
Closes the iterator and frees all resources.
|
void |
kill(java.lang.Throwable throwable)
Interrupt the operation, increasing the likelihood that it will terminate early with an error.
|
java.util.concurrent.CompletionStage<?> |
loadNextBatch()
Loads the next batch if there is still data available for loading.
|
boolean |
moveNext()
Advances the iterator.
|
void |
moveToStart()
Moves the Iterator back to the starting position.
|
Columns |
rowData()
This method returns a columns object which can be used to access the underlying data of the current iterator
position.
|
public AsyncOperationBatchIterator(BatchIterator source, int numColumns, BatchAccumulator<Row,java.util.Iterator<? extends Row>> batchAccumulator)
public Columns rowData()
BatchIterator
Input.value()
on any of the returned columns if the iterator is
positioned on a valid row, which is only the case if the last call to BatchIterator.moveNext()
returned true.
This method is valid to be called over the whole lifetime of the iterator, regardless of the state of the
iterator or its position. However it is good practice for consumers of this iterator to gather the columns
before iterating. This method is required to always return the same object on every call.rowData
in interface BatchIterator
public void moveToStart()
BatchIterator
BatchIterator.moveNext()
and BatchIterator.loadNextBatch()
as appropriate.moveToStart
in interface BatchIterator
public boolean moveNext()
BatchIterator
moveNext
in interface BatchIterator
BatchIterator.allLoaded()
returns true the iterator is out of data. Otherwise BatchIterator.loadNextBatch()
can be used to load the next batch - after which moveNext()
can be used again.public void close()
BatchIterator
close
in interface BatchIterator
public java.util.concurrent.CompletionStage<?> loadNextBatch()
BatchIterator
BatchIterator.allLoaded()
returns false.
If BatchIterator.allLoaded()
returns true, calling this method will return a failed CompletionStage.
NOTE: while loading takes place the iterator must not be moved. The iterator behaviour in this case is undetermined.
loadNextBatch
in interface BatchIterator
BatchIterator.moveNext()
can be called again if the next batch contains more data.public boolean allLoaded()
allLoaded
in interface BatchIterator
public void kill(@Nonnull java.lang.Throwable throwable)
Killable