Package org.apache.cassandra.index
Interface Index.QueryPlan
- All Superinterfaces:
Comparable<Index.QueryPlan>
- All Known Implementing Classes:
SASIIndexQueryPlan,SingletonIndexQueryPlan,StorageAttachedIndexQueryPlan
- Enclosing interface:
- Index
Specifies a set of compatible indexes to be used with a query according to its
RowFilter, ignoring data
ranges, limits, etc. All the indexes in it should belong to the same Index.Group.
It's created by Index.Group.queryPlanFor(org.apache.cassandra.db.filter.RowFilter) from the RowFilter that is common to all the subcommands of a
user query's ReadCommand, so it can be reused by those subcommands along the cluster nodes. The
searcherFor(ReadCommand) method provides the Index.Searcher object to read the index for each
particular (sub)command.
-
Method Summary
Modifier and TypeMethodDescriptiondefault intcompareTo(Index.QueryPlan other) default longReturn an estimate of the number of results this plan is expected to return for any givenReadCommandthat it can be used to answer.default IndexgetFirst()Returns the first index in this plan.Returns the indexes selected by this query plan, all of them belonging to the sameIndex.Group.default booleanisTopK()Transform an initialRowFilterinto the filter that will still need to applied to a set of Rows after the index has performed it's initial scan.default Function<PartitionIterator,PartitionIterator> postProcessor(ReadCommand command) Return a function which performs post processing on the results of a partition range read command.searcherFor(ReadCommand command) Factory method for query time search helper.default booleanUsed to determine whether to estimate initial concurrency during remote range reads.default booleansupportsReplicaFilteringProtection(RowFilter rowFilter) Tells whether this index supports replica fitering protection or not.default voidvalidate(ReadCommand command) Used to validate the various parameters of a suppliedReadCommandagainst the indexes in this plan.
-
Method Details
-
getIndexes
Returns the indexes selected by this query plan, all of them belonging to the sameIndex.Group. It should never be empty.- Returns:
- the indexes selected by this query plan, which is never empty
-
getFirst
Returns the first index in this plan.- Returns:
- the first index
-
getEstimatedResultRows
default long getEstimatedResultRows()Return an estimate of the number of results this plan is expected to return for any givenReadCommandthat it can be used to answer. Used bySecondaryIndexManager.getBestIndexQueryPlanFor(RowFilter)to determine theIndex.Groupwith the most selective plan for a givenRowFilter. Additionally, this is also used by StorageProxy.estimateResultsPerRange to calculate the initial concurrency factor for range requests- Returns:
- the estimated average number of results a Searcher may return for any given command
-
shouldEstimateInitialConcurrency
default boolean shouldEstimateInitialConcurrency()Used to determine whether to estimate initial concurrency during remote range reads. Default is true, each implementation must override this method if they choose a different strategy.- Returns:
- true if the
Index.QueryPlanshould estimate initial concurrency, false otherwise
-
compareTo
- Specified by:
compareToin interfaceComparable<Index.QueryPlan>
-
validate
Used to validate the various parameters of a suppliedReadCommandagainst the indexes in this plan.- Parameters:
command- a ReadCommand whose parameters are to be verified- Throws:
InvalidRequestException- if the details of the command fail to meet the validation rules of the indexes in the query plan
-
searcherFor
Factory method for query time search helper.- Parameters:
command- the read command being executed- Returns:
- an Searcher with which to perform the supplied command
-
postProcessor
Return a function which performs post processing on the results of a partition range read command. In future, this may be used as a generalized mechanism for transforming results on the coordinator prior to returning them to the caller. This is used on the coordinator during execution of a range command to perform post processing of merged results obtained from the necessary replicas. This is the only way in which results are transformed in this way but this may change over time as usage is generalized. See CASSANDRA-8717 for further discussion. The function takes a PartitionIterator of the results from the replicas which has already been collated and reconciled, along with the command being executed. It returns another PartitionIterator containing the results of the transformation (which may be the same as the input if the transformation is a no-op).- Parameters:
command- the read command being executed
-
postIndexQueryFilter
RowFilter postIndexQueryFilter()Transform an initialRowFilterinto the filter that will still need to applied to a set of Rows after the index has performed it's initial scan. Used inReadCommand.executeLocally(ReadExecutionController)to reduce the amount of filtering performed on the results of the index query.- Returns:
- the (hopefully) reduced filter that would still need to be applied after the index was used to narrow the initial result set
-
supportsReplicaFilteringProtection
Tells whether this index supports replica fitering protection or not. Replica filtering protection might need to run the query row filter in the coordinator to detect stale results. An index implementation will be compatible with this protection mechanism if it returns the same results for the row filter as CQL will return withALLOW FILTERINGand without using the index. This means that index implementations using custom query syntax or applying transformations to the indexed data won't support it. See CASSANDRA-8272 for further details.- Parameters:
rowFilter- rowFilter of query to decide if it supports replica filtering protection or not- Returns:
- true if this index supports replica filtering protection, false otherwise
-
isTopK
default boolean isTopK()- Returns:
- true if given index query plan is a top-k request
-