Interface PrepareRequest
-
- All Superinterfaces:
Request
public interface PrepareRequest extends Request
A request to prepare a CQL query.Driver clients should rarely have to deal directly with this type, it's used internally by
Session's prepare methods. However aRetryPolicyimplementation might use it if it needs a custom behavior for prepare requests.A client may also provide their own implementation of this interface to customize which attributes are propagated when preparing a simple statement; see
SyncCqlSession.prepare(SimpleStatement)for more explanations.
-
-
Field Summary
Fields Modifier and Type Field Description static GenericType<CompletionStage<PreparedStatement>>ASYNCThe type returned when a CQL statement is prepared asynchronously.static GenericType<PreparedStatement>SYNCThe type returned when a CQL statement is prepared synchronously.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description BooleanareBoundStatementsIdempotent()Whether bound statements that will be created from the prepared statement are idempotent.booleanareBoundStatementsTracing()Whether bound statements that will be created from the prepared statement are tracing.ConsistencyLevelgetConsistencyLevelForBoundStatements()The consistency level to use for the bound statements that will be created from the prepared statement ornullto use the default value from the configuration.Map<String,ByteBuffer>getCustomPayloadForBoundStatements()Returns the custom payload to send alongside the bound statements that will be created from the prepared statement.DriverExecutionProfilegetExecutionProfileForBoundStatements()The execution profile to use for the bound statements that will be created from the prepared statement.StringgetExecutionProfileNameForBoundStatements()The name of the execution profile to use for the bound statements that will be created from the prepared statement.intgetPageSizeForBoundStatements()The page size to use for the bound statements that will be created from the prepared statement.ByteBuffergetPagingStateForBoundStatements()The paging state to use for the bound statements that will be created from the prepared statement.StringgetQuery()The CQL query to prepare.ByteBuffergetRoutingKeyForBoundStatements()The routing key to use for the bound statements that will be created from the prepared statement.CqlIdentifiergetRoutingKeyspaceForBoundStatements()The routing keyspace to use for the bound statements that will be created from the prepared statement.TokengetRoutingTokenForBoundStatements()The routing key to use for the bound statements that will be created from the prepared statement.ConsistencyLevelgetSerialConsistencyLevelForBoundStatements()The serial consistency level to use for the bound statements that will be created from the prepared statement ornullto use the default value from the configuration.DurationgetTimeoutForBoundStatements()The timeout to use for the bound statements that will be created from the prepared statement.default BooleanisIdempotent()Whether the request is idempotent; that is, whether applying the request twice leaves the database in the same state.-
Methods inherited from interface com.datastax.oss.driver.api.core.session.Request
getCustomPayload, getExecutionProfile, getExecutionProfileName, getKeyspace, getNode, getPartitioner, getRequestRoutingType, getRoutingKey, getRoutingKeyspace, getRoutingTable, getRoutingToken, getTimeout
-
-
-
-
Field Detail
-
SYNC
static final GenericType<PreparedStatement> SYNC
The type returned when a CQL statement is prepared synchronously.Most users won't use this explicitly. It is needed for the generic execute method (
Session.execute(Request, GenericType)), but CQL statements will generally be prepared with one of the driver's built-in helper methods (such asSyncCqlSession.prepare(SimpleStatement)).
-
ASYNC
static final GenericType<CompletionStage<PreparedStatement>> ASYNC
The type returned when a CQL statement is prepared asynchronously.Most users won't use this explicitly. It is needed for the generic execute method (
Session.execute(Request, GenericType)), but CQL statements will generally be prepared with one of the driver's built-in helper methods (such asAsyncCqlSession.prepareAsync(SimpleStatement).
-
-
Method Detail
-
getQuery
@NonNull String getQuery()
The CQL query to prepare.
-
isIdempotent
@NonNull default Boolean isIdempotent()
Whether the request is idempotent; that is, whether applying the request twice leaves the database in the same state.This is used internally for retries and speculative executions: if a request is not idempotent, the driver will take extra care to ensure that it is not sent twice (for example, don't retry if there is the slightest chance that the request reached a coordinator).
Note that this refers to the prepare query itself, not to the bound statements that will be created from the prepared statement (see
areBoundStatementsIdempotent()).- Specified by:
isIdempotentin interfaceRequest- Returns:
- a boolean value, or
nullto use the default value defined in the configuration. - See Also:
DefaultDriverOption.REQUEST_DEFAULT_IDEMPOTENCE
-
getExecutionProfileNameForBoundStatements
@Nullable String getExecutionProfileNameForBoundStatements()
The name of the execution profile to use for the bound statements that will be created from the prepared statement.Note that this will be ignored if
getExecutionProfileForBoundStatements()returns a non-null value.
-
getExecutionProfileForBoundStatements
@Nullable DriverExecutionProfile getExecutionProfileForBoundStatements()
The execution profile to use for the bound statements that will be created from the prepared statement.
-
getRoutingKeyspaceForBoundStatements
CqlIdentifier getRoutingKeyspaceForBoundStatements()
The routing keyspace to use for the bound statements that will be created from the prepared statement.
-
getRoutingKeyForBoundStatements
ByteBuffer getRoutingKeyForBoundStatements()
The routing key to use for the bound statements that will be created from the prepared statement.
-
getRoutingTokenForBoundStatements
Token getRoutingTokenForBoundStatements()
The routing key to use for the bound statements that will be created from the prepared statement.If it's not null, it takes precedence over
getRoutingKeyForBoundStatements().
-
getCustomPayloadForBoundStatements
@NonNull Map<String,ByteBuffer> getCustomPayloadForBoundStatements()
Returns the custom payload to send alongside the bound statements that will be created from the prepared statement.
-
areBoundStatementsIdempotent
@Nullable Boolean areBoundStatementsIdempotent()
Whether bound statements that will be created from the prepared statement are idempotent.This follows the same semantics as
isIdempotent().
-
getTimeoutForBoundStatements
@Nullable Duration getTimeoutForBoundStatements()
The timeout to use for the bound statements that will be created from the prepared statement. If the value is null, the default value will be used from the configuration.
-
getPagingStateForBoundStatements
ByteBuffer getPagingStateForBoundStatements()
The paging state to use for the bound statements that will be created from the prepared statement.
-
getPageSizeForBoundStatements
int getPageSizeForBoundStatements()
The page size to use for the bound statements that will be created from the prepared statement. If the value is 0 or negative, the default value will be used from the configuration.
-
getConsistencyLevelForBoundStatements
@Nullable ConsistencyLevel getConsistencyLevelForBoundStatements()
The consistency level to use for the bound statements that will be created from the prepared statement ornullto use the default value from the configuration.
-
getSerialConsistencyLevelForBoundStatements
@Nullable ConsistencyLevel getSerialConsistencyLevelForBoundStatements()
The serial consistency level to use for the bound statements that will be created from the prepared statement ornullto use the default value from the configuration.
-
areBoundStatementsTracing
boolean areBoundStatementsTracing()
Whether bound statements that will be created from the prepared statement are tracing.
-
-