Class QueryOptions

java.lang.Object
org.apache.cassandra.cql3.QueryOptions

public abstract class QueryOptions extends Object
Options for a query.
  • Field Details

  • Constructor Details

    • QueryOptions

      public QueryOptions()
  • Method Details

    • forInternalCalls

      public static QueryOptions forInternalCalls(ConsistencyLevel consistency, List<ByteBuffer> values)
    • forInternalCallsWithNowInSec

      public static QueryOptions forInternalCallsWithNowInSec(long nowInSec, ConsistencyLevel consistency, List<ByteBuffer> values)
    • forInternalCalls

      public static QueryOptions forInternalCalls(List<ByteBuffer> values)
    • forProtocolVersion

      public static QueryOptions forProtocolVersion(ProtocolVersion protocolVersion)
    • 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

      public static QueryOptions withPageSize(QueryOptions options, int pageSize)
    • getConsistency

      public abstract ConsistencyLevel getConsistency()
    • getValues

      public abstract List<ByteBuffer> getValues()
    • skipMetadata

      public abstract boolean skipMetadata()
    • getJsonColumnValue

      public Term getJsonColumnValue(int bindIndex, ColumnIdentifier columnName, Collection<ColumnMetadata> expectedReceivers) throws InvalidRequestException
      Returns the term corresponding to column columnName in the JSON value of bind index bindIndex. 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 same bindIndex value, 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 index bindIndex. 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 same bindIndx values should use the same value for this parameter, but this isn't validated in any way.
      Returns:
      the value correspong to column columnName in the (JSON) bind value at index bindIndex. This may return null if the JSON value has no value for this column.
      Throws:
      InvalidRequestException
    • hasColumnSpecifications

      public boolean hasColumnSpecifications()
      Tells whether or not this QueryOptions contains the column specifications for the bound variables.

      The column specifications will be present only for prepared statements.

      Returns:
      true this QueryOptions contains the column specifications for the bound variables, false otherwise.
    • 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 this QueryOptions contains the column specifications.

      Returns:
      the option names
      Throws:
      UnsupportedOperationException - If this QueryOptions does not contains the column specifications.
    • getPageSize

      public int getPageSize()
      The pageSize for this query. Will be <= 0 if 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 long getNowInSeconds(QueryState state)
    • getKeyspace

      public String getKeyspace()
      The keyspace that this query is bound to, or null if not relevant.
    • getNowInSec

      public long getNowInSec(long 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(List<ColumnSpecification> specs)
    • toString

      public String toString()
      Overrides:
      toString in class Object