Package org.apache.cassandra.index
Interface Index.QueryPlan
-
- All Superinterfaces:
java.lang.Comparable<Index.QueryPlan>
- All Known Implementing Classes:
SASIIndexQueryPlan
,SingletonIndexQueryPlan
,StorageAttachedIndexQueryPlan
- Enclosing interface:
- Index
public static interface Index.QueryPlan extends java.lang.Comparable<Index.QueryPlan>
Specifies a set of compatible indexes to be used with a query according to itsRowFilter
, ignoring data ranges, limits, etc. All the indexes in it should belong to the sameIndex.Group
.It's created by
Index.Group.queryPlanFor(org.apache.cassandra.db.filter.RowFilter)
from theRowFilter
that is common to all the subcommands of a user query'sReadCommand
, so it can be reused by those subcommands along the cluster nodes. ThesearcherFor(ReadCommand)
method provides theIndex.Searcher
object to read the index for each particular (sub)command.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default int
compareTo(Index.QueryPlan other)
default long
getEstimatedResultRows()
Return an estimate of the number of results this plan is expected to return for any givenReadCommand
that it can be used to answer.default Index
getFirst()
Returns the first index in this plan.java.util.Set<Index>
getIndexes()
Returns the indexes selected by this query plan, all of them belonging to the sameIndex.Group
.default boolean
isTopK()
RowFilter
postIndexQueryFilter()
Transform an initialRowFilter
into the filter that will still need to applied to a set of Rows after the index has performed it's initial scan.default java.util.function.Function<PartitionIterator,PartitionIterator>
postProcessor(ReadCommand command)
Return a function which performs post processing on the results of a partition range read command.Index.Searcher
searcherFor(ReadCommand command)
Factory method for query time search helper.default boolean
shouldEstimateInitialConcurrency()
Used to determine whether to estimate initial concurrency during remote range reads.default boolean
supportsReplicaFilteringProtection(RowFilter rowFilter)
Tells whether this index supports replica fitering protection or not.default void
validate(ReadCommand command)
Used to validate the various parameters of a suppliedReadCommand
against the indexes in this plan.
-
-
-
Method Detail
-
getIndexes
java.util.Set<Index> 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
@Nonnull default Index 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 givenReadCommand
that it can be used to answer. Used bySecondaryIndexManager.getBestIndexQueryPlanFor(RowFilter)
to determine theIndex.Group
with 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.QueryPlan
should estimate initial concurrency, false otherwise
-
compareTo
default int compareTo(Index.QueryPlan other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Index.QueryPlan>
-
validate
default void validate(ReadCommand command) throws InvalidRequestException
Used to validate the various parameters of a suppliedReadCommand
against 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
Index.Searcher searcherFor(ReadCommand command)
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
default java.util.function.Function<PartitionIterator,PartitionIterator> postProcessor(ReadCommand command)
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 initialRowFilter
into 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
default boolean supportsReplicaFilteringProtection(RowFilter rowFilter)
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 FILTERING
and 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
-
-