Package org.apache.cassandra.cql3
Class QueryOptions
java.lang.Object
org.apache.cassandra.cql3.QueryOptions
Options for a query.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic QueryOptionsaddColumnSpecifications(QueryOptions options, List<ColumnSpecification> columnSpecs) static QueryOptionscreate(ConsistencyLevel consistency, List<ByteBuffer> values, boolean skipMetadata, int pageSize, PagingState pagingState, ConsistencyLevel serialConsistency, ProtocolVersion version, String keyspace) static QueryOptionscreate(ConsistencyLevel consistency, List<ByteBuffer> values, boolean skipMetadata, int pageSize, PagingState pagingState, ConsistencyLevel serialConsistency, ProtocolVersion version, String keyspace, long timestamp, long nowInSeconds) static QueryOptionsforInternalCalls(List<ByteBuffer> values) static QueryOptionsforInternalCalls(ConsistencyLevel consistency, List<ByteBuffer> values) static QueryOptionsforInternalCallsWithNowInSec(long nowInSec, ConsistencyLevel consistency, List<ByteBuffer> values) static QueryOptionsforProtocolVersion(ProtocolVersion protocolVersion) com.google.common.collect.ImmutableList<ColumnSpecification>Returns the column specifications for the bound variables (optional operation).abstract ConsistencyLevellonglonggetJsonColumnValue(int bindIndex, ColumnIdentifier columnName, Collection<ColumnMetadata> expectedReceivers) Returns the term corresponding to columncolumnNamein the JSON value of bind indexbindIndex.The keyspace that this query is bound to, or null if not relevant.longgetNowInSec(long ifNotSet) longgetNowInSeconds(QueryState state) intThe pageSize for this query.The paging state for this query, or null if not relevant.abstract ProtocolVersionThe protocol version for the query.Serial consistency for conditional updates.longgetTimestamp(QueryState state) abstract List<ByteBuffer>booleanTells whether or not thisQueryOptionscontains the column specifications for the bound variables.booleanprepare(List<ColumnSpecification> specs) abstract booleantoString()static QueryOptionswithConsistencyLevel(QueryOptions options, ConsistencyLevel consistencyLevel) static QueryOptionswithPageSize(QueryOptions options, int pageSize)
-
Field Details
-
DEFAULT
-
codec
-
-
Constructor Details
-
QueryOptions
public QueryOptions()
-
-
Method Details
-
forInternalCalls
-
forInternalCallsWithNowInSec
public static QueryOptions forInternalCallsWithNowInSec(long nowInSec, ConsistencyLevel consistency, List<ByteBuffer> values) -
forInternalCalls
-
forProtocolVersion
-
create
public static QueryOptions create(ConsistencyLevel consistency, List<ByteBuffer> values, boolean skipMetadata, int pageSize, PagingState pagingState, ConsistencyLevel serialConsistency, ProtocolVersion version, String keyspace) -
create
public static QueryOptions create(ConsistencyLevel consistency, List<ByteBuffer> values, boolean skipMetadata, int pageSize, PagingState pagingState, ConsistencyLevel serialConsistency, ProtocolVersion version, String keyspace, long timestamp, long nowInSeconds) -
addColumnSpecifications
public static QueryOptions addColumnSpecifications(QueryOptions options, List<ColumnSpecification> columnSpecs) -
withConsistencyLevel
public static QueryOptions withConsistencyLevel(QueryOptions options, ConsistencyLevel consistencyLevel) -
withPageSize
-
getConsistency
-
getValues
-
skipMetadata
public abstract boolean skipMetadata() -
getJsonColumnValue
public Term getJsonColumnValue(int bindIndex, ColumnIdentifier columnName, Collection<ColumnMetadata> expectedReceivers) throws InvalidRequestException Returns the term corresponding to columncolumnNamein the JSON value of bind indexbindIndex. This is functionally equivalent to:Json.parseJson(UTF8Type.instance.getSerializer().deserialize(getValues().get(bindIndex)), expectedReceivers).get(columnName)but this caches the result of parsing the JSON, so that while this might be called for multiple columns on the samebindIndexvalue, the underlying JSON value is only parsed/processed once. Note: this is a bit more involved in CQL specifics than this class generally is, but as we need to cache this per-query and in an object that is available when we bind values, this is the easiest place to have this.- Parameters:
bindIndex- the index of the bind value that should be interpreted as a JSON value.columnName- the name of the column we want the value of.expectedReceivers- the columns expected in the JSON value at indexbindIndex. This is only used when parsing the json initially and no check is done afterwards. So in practice, any call of this method on the same QueryOptions object and with the samebindIndxvalues should use the same value for this parameter, but this isn't validated in any way.- Returns:
- the value correspong to column
columnNamein the (JSON) bind value at indexbindIndex. This may return null if the JSON value has no value for this column. - Throws:
InvalidRequestException
-
hasColumnSpecifications
public boolean hasColumnSpecifications()Tells whether or not thisQueryOptionscontains the column specifications for the bound variables.The column specifications will be present only for prepared statements.
- Returns:
truethisQueryOptionscontains the column specifications for the bound variables,falseotherwise.
-
getColumnSpecifications
Returns the column specifications for the bound variables (optional operation).The column specifications will be present only for prepared statements.
Invoke the
hasColumnSpecifications()method before invoking this method in order to ensure that thisQueryOptionscontains the column specifications.- Returns:
- the option names
- Throws:
UnsupportedOperationException- If thisQueryOptionsdoes not contains the column specifications.
-
getPageSize
public int getPageSize()The pageSize for this query. Will be<= 0if not relevant for the query. -
getPagingState
The paging state for this query, or null if not relevant. -
getSerialConsistency
Serial consistency for conditional updates. -
getTimestamp
-
getNowInSeconds
-
getKeyspace
The keyspace that this query is bound to, or null if not relevant. -
getNowInSec
public long getNowInSec(long ifNotSet) -
getProtocolVersion
The protocol version for the query. -
isReadThresholdsEnabled
public boolean isReadThresholdsEnabled() -
getCoordinatorReadSizeWarnThresholdBytes
public long getCoordinatorReadSizeWarnThresholdBytes() -
getCoordinatorReadSizeAbortThresholdBytes
public long getCoordinatorReadSizeAbortThresholdBytes() -
prepare
-
toString
-