Class MergeCursorContinuation<B extends Message.Builder,C extends RecordCursorContinuation>
- java.lang.Object
-
- com.apple.foundationdb.record.provider.foundationdb.cursors.MergeCursorContinuation<B,C>
-
- Type Parameters:
B
- the builder for message type of the continuation proto messageC
- type of the continuation
- All Implemented Interfaces:
RecordCursorContinuation
@API(INTERNAL) public abstract class MergeCursorContinuation<B extends Message.Builder,C extends RecordCursorContinuation> extends Object implements RecordCursorContinuation
Common code for handling the continuations ofMergeCursor
s. The continuations for these cursors are constructed from a Protobuf message containing information on the state of each child cursor. This class handles caching that Protobuf message and its byte representation so that subsequent calls to get the continuation are fast. It also abstracts away some of the logic for converting a list of continuations into a single Protobuf message, but this is still somewhat clunky because Protobuf does not supportMessage
inheritance (which limits the opportunity for polymorphism).
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MergeCursorContinuation(List<C> continuations, Message originalProto)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
addOtherChild(B builder, C continuation)
Fill in the Protobuf builder with the information for a child other than the first or second child.protected List<C>
getContinuations()
protected abstract B
newProtoBuilder()
Get a new builder instance for the Protobuf message associated with this continuation.protected abstract void
setFirstChild(B builder, C continuation)
Fill in the Protobuf builder with the information from the first child.protected abstract void
setSecondChild(B builder, C continuation)
Fill in the Protobuf builder with the information from the second child.byte[]
toBytes()
Serialize this continuation to a byte array.protected Message
toProto()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.apple.foundationdb.record.RecordCursorContinuation
isEnd
-
-
-
-
Method Detail
-
setFirstChild
protected abstract void setFirstChild(@Nonnull B builder, @Nonnull C continuation)
Fill in the Protobuf builder with the information from the first child. For backwards-compatibility reasons, cursors may handle this differently than the other children. This method will be called beforesetSecondChild(B, C)
and all calls toaddOtherChild(B, C)
.- Parameters:
builder
- a builder for the Protobuf continuationcontinuation
- the first child's continuation
-
setSecondChild
protected abstract void setSecondChild(@Nonnull B builder, @Nonnull C continuation)
Fill in the Protobuf builder with the information from the second child. For backwards-compatibility reasons, cursors may handle this differently than the other children. This method will be called aftersetFirstChild(B, C)
and before all calls toaddOtherChild(B, C)
.- Parameters:
builder
- a builder for the Protobuf continuationcontinuation
- the second child's continuation
-
addOtherChild
protected abstract void addOtherChild(@Nonnull B builder, @Nonnull C continuation)
Fill in the Protobuf builder with the information for a child other than the first or second child. For backwards-compatibility reasons, cursors may handle those two children differently than the other children. This method will be called in the same order as the continuations ingetContinuations()
.- Parameters:
builder
- a builder for the Protobuf continuationcontinuation
- a child other than the first or second child
-
newProtoBuilder
@Nonnull protected abstract B newProtoBuilder()
Get a new builder instance for the Protobuf message associated with this continuation. This should typically be implemented by calling thenewBuilder()
method on the appropriate message type.- Returns:
- a new builder for the underlying Protobuf message type
-
toBytes
@Nullable public byte[] toBytes()
Description copied from interface:RecordCursorContinuation
Serialize this continuation to a byte array. This method must always return the same array contents (but not necessarily the same array). IfRecordCursorContinuation.isEnd()
returnstrue
, thentoBytes()
must returnnull
.- Specified by:
toBytes
in interfaceRecordCursorContinuation
- Returns:
- a (possibly null) byte array containing a binary serialization of this continuation
-
-