Interface QueryPlan<T>
-
- Type Parameters:
T
- the type of element produced by executing this plan
- All Superinterfaces:
Bindable
,Correlated<RelationalExpression>
,PlanHashable
,RelationalExpression
- All Known Subinterfaces:
RecordQueryPlan
,RecordQueryPlanWithChild
,RecordQueryPlanWithChildren
,RecordQueryPlanWithComparisons
,RecordQueryPlanWithIndex
,RecordQueryPlanWithNoChildren
,RecordQueryPlanWithRequiredFields
- All Known Implementing Classes:
ComposedBitmapIndexQueryPlan
,RecordQueryCoveringIndexPlan
,RecordQueryFetchFromPartialRecordPlan
,RecordQueryFilterPlan
,RecordQueryIndexPlan
,RecordQueryInJoinPlan
,RecordQueryInParameterJoinPlan
,RecordQueryIntersectionPlan
,RecordQueryInValuesJoinPlan
,RecordQueryLoadByKeysPlan
,RecordQueryPredicateFilterPlan
,RecordQueryScanPlan
,RecordQueryScoreForRankPlan
,RecordQueryTextIndexPlan
,RecordQueryTypeFilterPlan
,RecordQueryUnionPlan
,RecordQueryUnionPlanBase
,RecordQueryUnorderedDistinctPlan
,RecordQueryUnorderedPrimaryKeyDistinctPlan
,RecordQueryUnorderedUnionPlan
@API(EXPERIMENTAL) public interface QueryPlan<T> extends PlanHashable, RelationalExpression
An executable query plan. A query plan can be executed against a record store to get a stream of items. Unlike aRecordQueryPlan
(which extends this interface), implementations are not required to return records but might instead return items of an arbitrary type. Note thatQueryPlanner
s always returnRecordQueryPlan
s, but the query plan tree might contain intermediate plans that return something other than records.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.apple.foundationdb.record.query.plan.temp.Correlated
Correlated.BoundEquivalence
-
Nested classes/interfaces inherited from interface com.apple.foundationdb.record.PlanHashable
PlanHashable.PlanHashKind
-
Nested classes/interfaces inherited from interface com.apple.foundationdb.record.query.plan.temp.RelationalExpression
RelationalExpression.CombineFunction<R,S>, RelationalExpression.CombinePredicate
-
-
Field Summary
Fields Modifier and Type Field Description static int
UNKNOWN_MAX_CARDINALITY
The result ofmaxCardinality(com.apple.foundationdb.record.RecordMetaData)
is not known.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default RecordCursor<T>
execute(FDBRecordStore store)
Execute this query plan.default RecordCursor<T>
execute(FDBRecordStore store, EvaluationContext context)
Execute this query plan.RecordCursor<T>
execute(FDBRecordStore store, EvaluationContext context, byte[] continuation, ExecuteProperties executeProperties)
Execute this query plan.int
getComplexity()
Returns an integer representing the "complexity" of the generated plan.List<? extends QueryPlan<?>>
getQueryPlanChildren()
Returns the (zero or more) childQueryPlan
s of this plan.Set<String>
getUsedIndexes()
Returns a set of names of the indexes used by this plan (and its sub-plans).boolean
hasFullRecordScan()
Indicates whether this plan (or one of its components) must perform a scan over all records in the store directly rather than going through a secondary index.boolean
hasIndexScan(String indexName)
Indicates whether this plan scans the given index.boolean
hasLoadBykeys()
Indicates whether this plan (or one of its components) loads records by their primary key.boolean
hasRecordScan()
Indicates whether this plan (or one of its components) scans at least a subset of the record range directly rather than going through a secondary index.boolean
isReverse()
Indicates whether this plan will return values in "reverse" order from the natural order of results of this plan.void
logPlanStructure(StoreTimer timer)
Adds one to an appropriateStoreTimer
counter for each plan and subplan of this plan, allowing tracking of which plans are being chosen (e.g.default int
maxCardinality(RecordMetaData metaData)
Indicates how many records this plan could possibly return.-
Methods inherited from interface com.apple.foundationdb.record.query.plan.temp.Correlated
getCorrelatedTo, rebase
-
Methods inherited from interface com.apple.foundationdb.record.PlanHashable
planHash, planHash
-
Methods inherited from interface com.apple.foundationdb.record.query.plan.temp.RelationalExpression
acceptPropertyVisitor, adjustMatch, bindIdentities, bindTo, canCorrelate, compensate, enumerateUnboundCorrelatedTo, equalsWithoutChildren, exactlySubsumedBy, findMatches, getQuantifiers, getResultValues, hashCodeWithoutChildren, hasIncompatibleBoundQuantifiers, hasUnboundQuantifiers, match, match, semanticEquals, semanticEquals, semanticHashCode, show, subsumedBy
-
-
-
-
Field Detail
-
UNKNOWN_MAX_CARDINALITY
static final int UNKNOWN_MAX_CARDINALITY
The result ofmaxCardinality(com.apple.foundationdb.record.RecordMetaData)
is not known.- See Also:
- Constant Field Values
-
-
Method Detail
-
execute
@Nonnull RecordCursor<T> execute(@Nonnull FDBRecordStore store, @Nonnull EvaluationContext context, @Nullable byte[] continuation, @Nonnull ExecuteProperties executeProperties)
Execute this query plan.- Parameters:
store
- record store from which to fetch itemscontext
- evaluation context containing parameter bindingscontinuation
- continuation from a previous execution of this same planexecuteProperties
- limits on execution- Returns:
- a cursor of items that match the query criteria
-
execute
@Nonnull default RecordCursor<T> execute(@Nonnull FDBRecordStore store)
Execute this query plan.- Parameters:
store
- record store from which to fetch items- Returns:
- a cursor of items that match the query criteria
-
execute
@Nonnull default RecordCursor<T> execute(@Nonnull FDBRecordStore store, @Nonnull EvaluationContext context)
Execute this query plan.- Parameters:
store
- record store to accesscontext
- evaluation context containing parameter bindings- Returns:
- a cursor of items that match the query criteria
-
isReverse
boolean isReverse()
Indicates whether this plan will return values in "reverse" order from the natural order of results of this plan. The return value istrue
if the plan returns elements in descending order andfalse
if the elements are returned in ascending order.- Returns:
true
if this plan returns elements in reverse order
-
hasRecordScan
boolean hasRecordScan()
Indicates whether this plan (or one of its components) scans at least a subset of the record range directly rather than going through a secondary index. A plan may only scan over a subset of all records. Someone might not use any secondary indexes explicitly, but they might make use of the primary key index. For example, if they had a compound primary key, and they issued a query for all records that had some value for the first element of their primary key, the planner will produce a plan which scans over a subset of all records.- Returns:
true
if this plan (or one of its components) scans at least a subset of the records directly
-
hasFullRecordScan
boolean hasFullRecordScan()
Indicates whether this plan (or one of its components) must perform a scan over all records in the store directly rather than going through a secondary index. SeehasRecordScan
for the comparison between two methods.- Returns:
true
if this plan (or one of its components) must perform a scan over all records in the store directly
-
hasIndexScan
boolean hasIndexScan(@Nonnull String indexName)
Indicates whether this plan scans the given index.- Parameters:
indexName
- the name of the index to check for- Returns:
true
if this plan (or one of its children) scans the given index
-
getUsedIndexes
@Nonnull Set<String> getUsedIndexes()
Returns a set of names of the indexes used by this plan (and its sub-plans).- Returns:
- an set of indexes used by this plan
-
hasLoadBykeys
boolean hasLoadBykeys()
Indicates whether this plan (or one of its components) loads records by their primary key.- Returns:
true
if this plan (or one of its components) loads records by their primary key
-
maxCardinality
default int maxCardinality(@Nonnull RecordMetaData metaData)
Indicates how many records this plan could possibly return.- Parameters:
metaData
- meta-data to use to determine things like index uniqueness- Returns:
- the maximum number of records or
UNKNOWN_MAX_CARDINALITY
if not known
-
logPlanStructure
void logPlanStructure(StoreTimer timer)
Adds one to an appropriateStoreTimer
counter for each plan and subplan of this plan, allowing tracking of which plans are being chosen (e.g. index scan vs. full scan).- Parameters:
timer
- the counters to increment
-
getComplexity
int getComplexity()
Returns an integer representing the "complexity" of the generated plan. Currently, this should simply be the number of plans in the plan tree with this plan as the root (i.e. the number of descendants of this plan, including itself).- Returns:
- the complexity of this plan
-
getQueryPlanChildren
List<? extends QueryPlan<?>> getQueryPlanChildren()
Returns the (zero or more) childQueryPlan
s of this plan. These children may or may not return elements of the same type as their parent plan.Warning: This part of the API is currently undergoing active development. At some point in the future, this will be renamed
getChildren()
. This cannot be done at current, however, as it would require an incompatible change toRecordQueryPlan.getChildren()
. That method has been markedAPI.Status.UNSTABLE
as of version 2.5.- Returns:
- the child plans of this plan
-
-