@API(value=STABLE) public interface RecordCursorContinuation
RecordCursor
.
A RecordCursorContinuation
represents the current position of a cursor and can be used to restart a cursor
at a point immediately after the record returned with the continuation. As a result, it must include all the state
essential to the operation of the cursor tree. The continuation can also be serialized to an opaque byte array that
can be passed to a client.
For historical reasons, there is a subtle relationship between the isEnd()
and toBytes()
methods.
If isEnd()
returns true
, then toBytes()
must return null
. However, the converse need
not be true: toBytes()
may return null
even if isEnd()
returns false
. For an example
of why this necessary, see RecordCursorStartContinuation
and RecordCursorEndContinuation
.
When implementing a RecordCursorContinuation
, great care must be taken to ensure that the continuation does
not share any objects with its cursor that might be changed while the cursor executes. Once initialized, a
continuation must remain unchanged and valid even after the cursor has advanced further or even been closed. To see
an example of how this can be done, see the implementation of the
KeyValueCursor
's continuation.
Modifier and Type | Method and Description |
---|---|
boolean |
isEnd()
Return whether this continuation is an "end continuation", i.e., represents that the iteration has reached
its end and would not produce more results even if restarted.
|
byte[] |
toBytes()
Serialize this continuation to a byte array.
|
@Nullable byte[] toBytes()
isEnd()
returns true
, then toBytes()
must return
null
.boolean isEnd()
isEnd()
returns true
, then
toBytes()
must return null
.