public interface BatchIterator extends Killable
loadNextBatch()
method.
The loaded data can be accessed by moving the iterator via the movement methods moveNext()
and
moveToStart()
and then using the Columns
object returned by rowData()
to access the data
at the current position.
Once all loaded data has been consumed more data can be loaded with loadNextBatch()
unless allLoaded()
is true in which case the iterator is exhausted.
A BatchIterator starts either *before* the first row or in an unloaded state.
This means a consumer can consume a BatchIterator like this:
while (it.moveNext()) { // do something with the row } if (it.allLoaded()) { // iterator is exhausted } else { it.loadNextBatch().whenComplete((r, t) -> { // continue consumption } }Thread-safety notes: Concurrent usage of a BatchIterator is not supported.
Modifier and Type | Method and Description |
---|---|
boolean |
allLoaded() |
void |
close()
Closes the iterator and frees all resources.
|
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.
|
Columns rowData()
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 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.void moveToStart()
moveNext()
and loadNextBatch()
as appropriate.java.lang.IllegalStateException
- if the cursor is closedboolean moveNext()
allLoaded()
returns true the iterator is out of data. Otherwise loadNextBatch()
can be used to load the next batch - after which moveNext()
can be used again.java.lang.IllegalStateException
- if the cursor is closedvoid close()
java.util.concurrent.CompletionStage<?> loadNextBatch()
allLoaded()
returns false.
If 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.
moveNext()
can be called again if the next batch contains more data.boolean allLoaded()
java.lang.IllegalStateException
- if the cursor is closed