Package org.apache.cassandra.cql3
Class QueryOptions
- java.lang.Object
-
- org.apache.cassandra.cql3.QueryOptions
-
public abstract class QueryOptions extends java.lang.ObjectOptions for a query.
-
-
Field Summary
Fields Modifier and Type Field Description static CBCodec<QueryOptions>codecstatic QueryOptionsDEFAULT
-
Constructor Summary
Constructors Constructor Description QueryOptions()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static QueryOptionsaddColumnSpecifications(QueryOptions options, java.util.List<ColumnSpecification> columnSpecs)static QueryOptionscreate(ConsistencyLevel consistency, java.util.List<java.nio.ByteBuffer> values, boolean skipMetadata, int pageSize, PagingState pagingState, ConsistencyLevel serialConsistency, ProtocolVersion version, java.lang.String keyspace)static QueryOptionscreate(ConsistencyLevel consistency, java.util.List<java.nio.ByteBuffer> values, boolean skipMetadata, int pageSize, PagingState pagingState, ConsistencyLevel serialConsistency, ProtocolVersion version, java.lang.String keyspace, long timestamp, int nowInSeconds)static QueryOptionsforInternalCalls(java.util.List<java.nio.ByteBuffer> values)static QueryOptionsforInternalCalls(ConsistencyLevel consistency, java.util.List<java.nio.ByteBuffer> values)static QueryOptionsforInternalCallsWithNowInSec(int nowInSec, ConsistencyLevel consistency, java.util.List<java.nio.ByteBuffer> values)static QueryOptionsforProtocolVersion(ProtocolVersion protocolVersion)com.google.common.collect.ImmutableList<ColumnSpecification>getColumnSpecifications()Returns the column specifications for the bound variables (optional operation).abstract ConsistencyLevelgetConsistency()longgetCoordinatorReadSizeAbortThresholdBytes()longgetCoordinatorReadSizeWarnThresholdBytes()TermgetJsonColumnValue(int bindIndex, ColumnIdentifier columnName, java.util.Collection<ColumnMetadata> expectedReceivers)Returns the term corresponding to columncolumnNamein the JSON value of bind indexbindIndex.java.lang.StringgetKeyspace()The keyspace that this query is bound to, or null if not relevant.intgetNowInSec(int ifNotSet)intgetNowInSeconds(QueryState state)intgetPageSize()The pageSize for this query.PagingStategetPagingState()The paging state for this query, or null if not relevant.abstract ProtocolVersiongetProtocolVersion()The protocol version for the query.ConsistencyLevelgetSerialConsistency()Serial consistency for conditional updates.longgetTimestamp(QueryState state)abstract java.util.List<java.nio.ByteBuffer>getValues()booleanhasColumnSpecifications()Tells whether or not thisQueryOptionscontains the column specifications for the bound variables.booleanisReadThresholdsEnabled()QueryOptionsprepare(java.util.List<ColumnSpecification> specs)abstract booleanskipMetadata()java.lang.StringtoString()
-
-
-
Field Detail
-
DEFAULT
public static final QueryOptions DEFAULT
-
codec
public static final CBCodec<QueryOptions> codec
-
-
Method Detail
-
forInternalCalls
public static QueryOptions forInternalCalls(ConsistencyLevel consistency, java.util.List<java.nio.ByteBuffer> values)
-
forInternalCallsWithNowInSec
public static QueryOptions forInternalCallsWithNowInSec(int nowInSec, ConsistencyLevel consistency, java.util.List<java.nio.ByteBuffer> values)
-
forInternalCalls
public static QueryOptions forInternalCalls(java.util.List<java.nio.ByteBuffer> values)
-
forProtocolVersion
public static QueryOptions forProtocolVersion(ProtocolVersion protocolVersion)
-
create
public static QueryOptions create(ConsistencyLevel consistency, java.util.List<java.nio.ByteBuffer> values, boolean skipMetadata, int pageSize, PagingState pagingState, ConsistencyLevel serialConsistency, ProtocolVersion version, java.lang.String keyspace)
-
create
public static QueryOptions create(ConsistencyLevel consistency, java.util.List<java.nio.ByteBuffer> values, boolean skipMetadata, int pageSize, PagingState pagingState, ConsistencyLevel serialConsistency, ProtocolVersion version, java.lang.String keyspace, long timestamp, int nowInSeconds)
-
addColumnSpecifications
public static QueryOptions addColumnSpecifications(QueryOptions options, java.util.List<ColumnSpecification> columnSpecs)
-
getConsistency
public abstract ConsistencyLevel getConsistency()
-
getValues
public abstract java.util.List<java.nio.ByteBuffer> getValues()
-
skipMetadata
public abstract boolean skipMetadata()
-
getJsonColumnValue
public Term getJsonColumnValue(int bindIndex, ColumnIdentifier columnName, java.util.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
public com.google.common.collect.ImmutableList<ColumnSpecification> 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:
java.lang.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
public PagingState getPagingState()
The paging state for this query, or null if not relevant.
-
getSerialConsistency
public ConsistencyLevel getSerialConsistency()
Serial consistency for conditional updates.
-
getTimestamp
public long getTimestamp(QueryState state)
-
getNowInSeconds
public int getNowInSeconds(QueryState state)
-
getKeyspace
public java.lang.String getKeyspace()
The keyspace that this query is bound to, or null if not relevant.
-
getNowInSec
public int getNowInSec(int ifNotSet)
-
getProtocolVersion
public abstract ProtocolVersion getProtocolVersion()
The protocol version for the query.
-
isReadThresholdsEnabled
public boolean isReadThresholdsEnabled()
-
getCoordinatorReadSizeWarnThresholdBytes
public long getCoordinatorReadSizeWarnThresholdBytes()
-
getCoordinatorReadSizeAbortThresholdBytes
public long getCoordinatorReadSizeAbortThresholdBytes()
-
prepare
public QueryOptions prepare(java.util.List<ColumnSpecification> specs)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-