T
- the type of elements of the cursor@API(value=STABLE) public class RecordCursorIterator<T> extends Object implements AsyncIterator<T>, AutoCloseable
RecordCursor
and presents an iterator-style interface for advancing
the cursor. This adds getContinuation()
and getNoNextReason()
methods to the AsyncIterator
interface so that cursors can be resumed and so that their reason for stopping can be inspected.Modifier and Type | Method and Description |
---|---|
void |
cancel() |
void |
close() |
byte[] |
getContinuation()
Get a byte string that can be used to continue a query after the last record returned.
|
RecordCursor.NoNextReason |
getNoNextReason()
Get the reason that the cursor has reached the end and returned
false for hasNext() . |
boolean |
hasNext()
Synchronously check whether there are more records available from the cursor.
|
T |
next()
Return the next value.
|
CompletableFuture<Boolean> |
onHasNext()
Asynchronously check whether there are more records available from the cursor.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining, remove
@Nonnull public CompletableFuture<Boolean> onHasNext()
onHasNext
in interface AsyncIterator<T>
true
if next()
would return a record.AsyncIterator.onHasNext()
public boolean hasNext()
@Nullable public T next()
onHasNext()
has completed to
true
(or equivalently after hasNext()
has returned true
).@Nullable public byte[] getContinuation()
null
if the underlying source is completely exhausted, independent of any limit passed to the
cursor creator. Since such creators generally accept null
to mean no continuation, that is, start from
the beginning, one must check for null
from getContinuation()
to keep from starting over.
Result is not always defined if called before the onHasNext()
has been called, before the returned
future has completed, or after it has completed to true
but before next()
has been called.
That is, a continuation is only guaranteed when called "between" records from a while (hasNext) next
loop
or after its end. If configured to do so, an IllegalContinuationAccessChecker
will be used to throw
an exception if a continuation is accessed at the wrong time.@Nonnull public RecordCursor.NoNextReason getNoNextReason()
false
for hasNext()
.
If hasNext
was not called or returned true
last time, the result is undefined and
may be an exception.public void close()
close
in interface AutoCloseable
public void cancel()
cancel
in interface AsyncIterator<T>