Interface RecordCursorContinuation

  • All Known Implementing Classes:
    ByteArrayContinuation, MergeCursorContinuation, RecordCursorEndContinuation, RecordCursorStartContinuation

    @API(STABLE)
    public interface RecordCursorContinuation
    An interface for types that represent the continuation of a 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.

    • 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). If isEnd() returns true, then toBytes() must return null.
        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. If isEnd() returns true, then toBytes() must return null.
        Returns:
        whether this continuation represents the end of a cursor's iteration