public interface PagingState
This class performs additional checks to fail fast if the paging state is not reused on the same query, and it provides utility methods for conversion to/from strings and byte arrays.
The serialized form returned by toBytes()
and Object.toString()
is an opaque
sequence of bytes. Note however that it is not cryptographically secure: the contents are
not encrypted and the checks are performed with a simple MD5 checksum. If you need stronger
guarantees, you should build your own wrapper around ExecutionInfo.getPagingState()
.
Modifier and Type | Method and Description |
---|---|
static PagingState |
fromBytes(byte[] bytes)
Parses an instance from a byte array previously generated with
toBytes() . |
static PagingState |
fromString(String string)
Parses an instance from a string previously generated with
toString() . |
ByteBuffer |
getRawPagingState()
Returns the underlying "unsafe" paging state (the equivalent of
ExecutionInfo.getPagingState() ). |
default boolean |
matches(Statement<?> statement)
Checks if this paging state can be safely reused for the given statement.
|
boolean |
matches(Statement<?> statement,
Session session)
Alternative to
matches(Statement) that specifies the session the statement will be
executed with. |
byte[] |
toBytes()
Returns a representation of this object as a byte array.
|
@NonNull static PagingState fromString(@NonNull String string)
toString()
.@NonNull static PagingState fromBytes(byte[] bytes)
toBytes()
.byte[] toBytes()
default boolean matches(@NonNull Statement<?> statement)
Note that, if statement
is a SimpleStatement
with bound values, those values
must be encoded in order to perform the check. This method uses the default codec registry and
default protocol version. This might fail if you use custom codecs; in that case, use matches(Statement, Session)
instead.
If statement
is a BoundStatement
, it is always safe to call this method.
boolean matches(@NonNull Statement<?> statement, @Nullable Session session)
matches(Statement)
that specifies the session the statement will be
executed with. You only need this for simple statements, and if you use custom codecs.
Bound statements already know which session they are attached to.@NonNull ByteBuffer getRawPagingState()
ExecutionInfo.getPagingState()
).Copyright © 2017–2022. All rights reserved.