Class SelectStatement
java.lang.Object
org.apache.cassandra.cql3.statements.SelectStatement
- All Implemented Interfaces:
CQLStatement,CQLStatement.SingleKeyspaceCqlStatement
@ThreadSafe
public class SelectStatement
extends Object
implements CQLStatement.SingleKeyspaceCqlStatement
Encapsulates a completely parsed SELECT query, including the target
column family, expression, result count, and ordering clause.
A number of public methods here are only used internally. However, many of these are made accessible for the benefit of custom QueryHandler implementations, so before reducing their accessibility due consideration should be given.
Note that select statements can be accessed by multiple threads, so we cannot rely on mutable attributes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classNested classes/interfaces inherited from interface org.apache.cassandra.cql3.CQLStatement
CQLStatement.Raw, CQLStatement.SingleKeyspaceCqlStatement -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal VariableSpecificationsstatic final intfinal TableMetadatastatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionSelectStatement(TableMetadata table, VariableSpecifications bindVariables, SelectStatement.Parameters parameters, Selection selection, StatementRestrictions restrictions, boolean isReversed, AggregationSpecification.Factory aggregationSpecFactory, org.apache.cassandra.cql3.statements.SelectStatement.ColumnComparator<List<ByteBuffer>> orderingComparator, Term limit, Term perPartitionLimit) -
Method Summary
Modifier and TypeMethodDescriptionvoidauthorize(ClientState state) Perform any access verification necessary for the statement.Returns the slices fetched by this SELECT, assuming an internal call (no bound values in particular).execute(QueryState state, QueryOptions options, Dispatcher.RequestTime requestTime) Execute the statement and return the resulting result or null if there is no result.executeInternal(QueryState state, QueryOptions options, long nowInSec, Dispatcher.RequestTime requestTime) executeLocally(QueryState state, QueryOptions options) Variant of execute used for internal query against the system tables, and thus only query the local node.executeRawInternal(QueryOptions options, ClientState state, long nowInSec) getAggregationSpec(QueryOptions options) Provides the context needed for audit logging statements.Returns all bind variables for the statementstatic ByteBuffer[]getComponents(TableMetadata metadata, DecoratedKey dk) Return an Iterable over all of the functions (both native and user-defined) used by any component of the statementintgetLimit(QueryOptions options) Returns the limit specified by the user.short[]Returns an array with the same length as the number of partition key columns for the table corresponding to table.intgetPerPartitionLimit(QueryOptions options) Returns the per partition limit specified by the user.getQuery(QueryOptions options, long nowInSec) getQuery(QueryOptions options, ClientState state, ColumnFilter columnFilter, long nowInSec, int userLimit, int perPartitionLimit, int pageSize, AggregationSpecification aggregationSpec) getQuery(QueryOptions options, ClientState state, ColumnFilter columnFilter, long nowInSec, DataLimits limit) May be used by custom QueryHandler implementationsgetRowFilter(QueryOptions options, ClientState state) May be used by custom QueryHandler implementationsMay be used by custom QueryHandler implementationsinternalReadForView(DecoratedKey key, long nowInSec) Returns a read command that can be used internally to query all the rows queried by this SELECT for a give key (used for materialized views).keyspace()makeSlices(QueryOptions options) process(PartitionIterator partitions, long nowInSec, boolean unmask, ClientState state) voidprocessPartition(RowIterator partition, QueryOptions options, ResultSetBuilder result, long nowInSec) The columns to fetch internally for this SELECT statement (which can be more than the one selected by the user as it also include any restricted column in particular).TheRowFilterfor this SELECT, assuming an internal call (no bound values in particular).table()toString()voidvalidate(ClientState state) Perform additional validation required by the statment.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.cassandra.cql3.CQLStatement
hasConditions
-
Field Details
-
DEFAULT_PAGE_SIZE
public static final int DEFAULT_PAGE_SIZE- See Also:
-
TOPK_CONSISTENCY_LEVEL_ERROR
- See Also:
-
TOPK_LIMIT_ERROR
- See Also:
-
TOPK_PARTITION_LIMIT_ERROR
- See Also:
-
TOPK_AGGREGATION_ERROR
- See Also:
-
TOPK_CONSISTENCY_LEVEL_WARNING
- See Also:
-
TOPK_PAGE_SIZE_WARNING
- See Also:
-
bindVariables
-
table
-
parameters
-
-
Constructor Details
-
SelectStatement
public SelectStatement(TableMetadata table, VariableSpecifications bindVariables, SelectStatement.Parameters parameters, Selection selection, StatementRestrictions restrictions, boolean isReversed, AggregationSpecification.Factory aggregationSpecFactory, org.apache.cassandra.cql3.statements.SelectStatement.ColumnComparator<List<ByteBuffer>> orderingComparator, Term limit, Term perPartitionLimit)
-
-
Method Details
-
getBindVariables
Description copied from interface:CQLStatementReturns all bind variables for the statement- Specified by:
getBindVariablesin interfaceCQLStatement
-
getPartitionKeyBindVariableIndexes
public short[] getPartitionKeyBindVariableIndexes()Description copied from interface:CQLStatementReturns an array with the same length as the number of partition key columns for the table corresponding to table. Each short in the array represents the bind index of the marker that holds the value for that partition key column. If there are no bind markers for any of the partition key columns, null is returned.- Specified by:
getPartitionKeyBindVariableIndexesin interfaceCQLStatement
-
getFunctions
Description copied from interface:CQLStatementReturn an Iterable over all of the functions (both native and user-defined) used by any component of the statement- Specified by:
getFunctionsin interfaceCQLStatement- Returns:
- functions all functions found (may contain duplicates)
-
queriedColumns
The columns to fetch internally for this SELECT statement (which can be more than the one selected by the user as it also include any restricted column in particular). -
getResultMetadata
-
authorize
Description copied from interface:CQLStatementPerform any access verification necessary for the statement.- Specified by:
authorizein interfaceCQLStatement- Parameters:
state- the current client state- Throws:
InvalidRequestExceptionUnauthorizedException
-
validate
Description copied from interface:CQLStatementPerform additional validation required by the statment. To be overriden by subclasses if needed.- Specified by:
validatein interfaceCQLStatement- Parameters:
state- the current client state- Throws:
InvalidRequestException
-
execute
public ResultMessage.Rows execute(QueryState state, QueryOptions options, Dispatcher.RequestTime requestTime) Description copied from interface:CQLStatementExecute the statement and return the resulting result or null if there is no result.- Specified by:
executein interfaceCQLStatement- Parameters:
state- the current query stateoptions- options for this query (consistency, variables, pageSize, ...)requestTime- request enqueue / and start times;
-
getAggregationSpec
-
getQuery
- Throws:
RequestValidationException
-
getQuery
public ReadQuery getQuery(QueryOptions options, ClientState state, ColumnFilter columnFilter, long nowInSec, int userLimit, int perPartitionLimit, int pageSize, AggregationSpecification aggregationSpec) -
getQuery
public ReadQuery getQuery(QueryOptions options, ClientState state, ColumnFilter columnFilter, long nowInSec, DataLimits limit) -
getAuditLogContext
Description copied from interface:CQLStatementProvides the context needed for audit logging statements.- Specified by:
getAuditLogContextin interfaceCQLStatement
-
executeLocally
public ResultMessage.Rows executeLocally(QueryState state, QueryOptions options) throws RequestExecutionException, RequestValidationException Description copied from interface:CQLStatementVariant of execute used for internal query against the system tables, and thus only query the local node.- Specified by:
executeLocallyin interfaceCQLStatement- Parameters:
state- the current query state- Throws:
RequestExecutionExceptionRequestValidationException
-
executeInternal
public ResultMessage.Rows executeInternal(QueryState state, QueryOptions options, long nowInSec, Dispatcher.RequestTime requestTime) -
executeRawInternal
public Map<DecoratedKey,List<Row>> executeRawInternal(QueryOptions options, ClientState state, long nowInSec) throws RequestExecutionException, RequestValidationException -
process
public ResultSet process(PartitionIterator partitions, long nowInSec, boolean unmask, ClientState state) throws InvalidRequestException - Throws:
InvalidRequestException
-
keyspace
- Specified by:
keyspacein interfaceCQLStatement.SingleKeyspaceCqlStatement
-
table
-
getSelection
May be used by custom QueryHandler implementations -
getRestrictions
May be used by custom QueryHandler implementations -
clusteringIndexFilterAsSlices
Returns the slices fetched by this SELECT, assuming an internal call (no bound values in particular).Note that if the SELECT intrinsically selects rows by names, we convert them into equivalent slices for the purpose of this method. This is used for MVs to restrict what needs to be read when we want to read everything that could be affected by a given view (and so, if the view SELECT statement has restrictions on the clustering columns, we can restrict what we read).
-
internalReadForView
Returns a read command that can be used internally to query all the rows queried by this SELECT for a give key (used for materialized views). -
rowFilterForInternalCalls
TheRowFilterfor this SELECT, assuming an internal call (no bound values in particular). -
makeSlices
- Throws:
InvalidRequestException
-
getLimit
Returns the limit specified by the user. May be used by custom QueryHandler implementations- Returns:
- the limit specified by the user or
DataLimits.NO_LIMITif no value as been specified.
-
getPerPartitionLimit
Returns the per partition limit specified by the user. May be used by custom QueryHandler implementations- Returns:
- the per partition limit specified by the user or
DataLimits.NO_LIMITif no value as been specified.
-
getRowFilter
public RowFilter getRowFilter(QueryOptions options, ClientState state) throws InvalidRequestException May be used by custom QueryHandler implementations- Throws:
InvalidRequestException
-
getComponents
-
processPartition
public void processPartition(RowIterator partition, QueryOptions options, ResultSetBuilder result, long nowInSec) throws InvalidRequestException - Throws:
InvalidRequestException
-
toString
-