Interface RecordCursorContinuation
-
- All Known Implementing Classes:
ByteArrayContinuation
,MergeCursorContinuation
,RecordCursorEndContinuation
,RecordCursorStartContinuation
@API(STABLE) public interface RecordCursorContinuation
An interface for types that represent the continuation of aRecordCursor
.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()
andtoBytes()
methods. IfisEnd()
returnstrue
, thentoBytes()
must returnnull
. However, the converse need not be true:toBytes()
may returnnull
even ifisEnd()
returnsfalse
. For an example of why this necessary, seeRecordCursorStartContinuation
andRecordCursorEndContinuation
.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 theKeyValueCursor
's continuation.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
toBytes
@Nullable byte[] toBytes()
Serialize this continuation to a byte array. This method must always return the same array contents (but not necessarily the same array). IfisEnd()
returnstrue
, thentoBytes()
must returnnull
.- Returns:
- a (possibly null) byte array containing a binary serialization of this continuation
-
isEnd
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. IfisEnd()
returnstrue
, thentoBytes()
must returnnull
.- Returns:
- whether this continuation represents the end of a cursor's iteration
-
-