Search in sources :

Example 1 with DefaultPagingState

use of com.datastax.oss.driver.internal.core.cql.DefaultPagingState in project java-driver by datastax.

the class ExecutionInfo method getSafePagingState.

/**
 * The paging state of the query, in a safe wrapper that checks if it's reused on the right
 * statement.
 *
 * <p>This represents the next page to be fetched if this query has multiple page of results. It
 * can be saved and reused later on the same statement.
 *
 * @return the paging state, or {@code null} if there is no next page.
 */
@Nullable
default PagingState getSafePagingState() {
    // Default implementation for backward compatibility, but we override it in the concrete class,
    // because it knows the attachment point.
    ByteBuffer rawPagingState = getPagingState();
    if (rawPagingState == null) {
        return null;
    } else {
        Request request = getRequest();
        if (!(request instanceof Statement)) {
            throw new IllegalStateException("Only statements should have a paging state");
        }
        Statement<?> statement = (Statement<?>) request;
        return new DefaultPagingState(rawPagingState, statement, AttachmentPoint.NONE);
    }
}
Also used : DefaultPagingState(com.datastax.oss.driver.internal.core.cql.DefaultPagingState) Request(com.datastax.oss.driver.api.core.session.Request) ByteBuffer(java.nio.ByteBuffer) Nullable(edu.umd.cs.findbugs.annotations.Nullable)

Aggregations

Request (com.datastax.oss.driver.api.core.session.Request)1 DefaultPagingState (com.datastax.oss.driver.internal.core.cql.DefaultPagingState)1 Nullable (edu.umd.cs.findbugs.annotations.Nullable)1 ByteBuffer (java.nio.ByteBuffer)1