Class RecordQueryCoveringIndexPlan
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.plans.RecordQueryCoveringIndexPlan
-
- All Implemented Interfaces:
PlanHashable
,QueryPlan<FDBQueriedRecord<Message>>
,RecordQueryPlan
,RecordQueryPlanWithNoChildren
,Bindable
,Correlated<RelationalExpression>
,PlannerGraphRewritable
,RelationalExpression
@API(INTERNAL) public class RecordQueryCoveringIndexPlan extends Object implements RecordQueryPlanWithNoChildren
A query plan that reconstructs records from the entries in a covering index.
-
-
Nested Class Summary
-
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 inherited from interface com.apple.foundationdb.record.query.plan.plans.QueryPlan
UNKNOWN_MAX_CARDINALITY
-
-
Constructor Summary
Constructors Constructor Description RecordQueryCoveringIndexPlan(RecordQueryPlanWithIndex indexPlan, String recordTypeName, AvailableFields availableFields, IndexKeyValueToPartialRecord toRecord)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object other)
boolean
equalsWithoutChildren(RelationalExpression otherExpression, AliasMap equivalencesMap)
<M extends Message>
RecordCursor<FDBQueriedRecord<M>>execute(FDBRecordStoreBase<M> store, EvaluationContext context, byte[] continuation, ExecuteProperties executeProperties)
Execute this query plan.AvailableFields
getAvailableFields()
int
getComplexity()
Returns an integer representing the "complexity" of the generated plan.Set<CorrelationIdentifier>
getCorrelatedTo()
Returns the set ofCorrelationIdentifier
s this entity is correlated to.String
getIndexName()
RecordQueryPlanWithIndex
getIndexPlan()
List<? extends Quantifier>
getQuantifiers()
Return an iterator of references to the children of this planner expression.IndexScanType
getScanType()
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.int
hashCode()
int
hashCodeWithoutChildren()
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.<M extends Message>
Function<IndexEntry,FDBQueriedRecord<M>>indexEntryToQueriedRecord(FDBRecordStoreBase<M> store)
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.int
maxCardinality(RecordMetaData metaData)
Indicates how many records this plan could possibly return.int
planHash(PlanHashable.PlanHashKind hashKind)
Return a hash similar tohashCode
, but with the additional guarantee that is is stable across JVMs.RecordQueryCoveringIndexPlan
rebase(AliasMap translationMap)
Rebases this and all other objects this objects is composed of using a given translation map.PlannerGraph
rewritePlannerGraph(List<? extends PlannerGraph> childGraphs)
Method to rewrite the planner graph.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.apple.foundationdb.record.PlanHashable
planHash
-
Methods inherited from interface com.apple.foundationdb.record.query.plan.plans.QueryPlan
execute, execute
-
Methods inherited from interface com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan
accept, execute, execute, execute, getQueryPlanChildren, structuralEquals, structuralEquals, structuralHashCode
-
Methods inherited from interface com.apple.foundationdb.record.query.plan.plans.RecordQueryPlanWithNoChildren
getChildren
-
Methods inherited from interface com.apple.foundationdb.record.query.plan.temp.RelationalExpression
acceptPropertyVisitor, bindIdentities, bindTo, canCorrelate, enumerateUnboundCorrelatedTo, findMatches, match, semanticEquals, semanticEquals, semanticHashCode, show
-
-
-
-
Constructor Detail
-
RecordQueryCoveringIndexPlan
public RecordQueryCoveringIndexPlan(@Nonnull RecordQueryPlanWithIndex indexPlan, @Nonnull String recordTypeName, @Nonnull AvailableFields availableFields, @Nonnull IndexKeyValueToPartialRecord toRecord)
-
-
Method Detail
-
execute
@Nonnull public <M extends Message> RecordCursor<FDBQueriedRecord<M>> execute(@Nonnull FDBRecordStoreBase<M> store, @Nonnull EvaluationContext context, @Nullable byte[] continuation, @Nonnull ExecuteProperties executeProperties)
Description copied from interface:RecordQueryPlan
Execute this query plan.- Specified by:
execute
in interfaceRecordQueryPlan
- Type Parameters:
M
- type used to represent stored records- Parameters:
store
- record store from which to fetch recordscontext
- evaluation context containing parameter bindingscontinuation
- continuation from a previous execution of this same planexecuteProperties
- limits on execution- Returns:
- a cursor of records that match the query criteria
-
indexEntryToQueriedRecord
@Nonnull @API(INTERNAL) public <M extends Message> Function<IndexEntry,FDBQueriedRecord<M>> indexEntryToQueriedRecord(@Nonnull FDBRecordStoreBase<M> store)
-
getIndexPlan
@Nonnull public RecordQueryPlanWithIndex getIndexPlan()
-
getScanType
@Nonnull public IndexScanType getScanType()
-
isReverse
public boolean isReverse()
Description copied from interface:QueryPlan
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.- Specified by:
isReverse
in interfaceQueryPlan<FDBQueriedRecord<Message>>
- Returns:
true
if this plan returns elements in reverse order
-
hasRecordScan
public boolean hasRecordScan()
Description copied from interface:QueryPlan
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.- Specified by:
hasRecordScan
in interfaceQueryPlan<FDBQueriedRecord<Message>>
- Returns:
true
if this plan (or one of its components) scans at least a subset of the records directly
-
hasFullRecordScan
public boolean hasFullRecordScan()
Description copied from interface:QueryPlan
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.- Specified by:
hasFullRecordScan
in interfaceQueryPlan<FDBQueriedRecord<Message>>
- Returns:
true
if this plan (or one of its components) must perform a scan over all records in the store directly
-
hasIndexScan
public boolean hasIndexScan(@Nonnull String indexName)
Description copied from interface:QueryPlan
Indicates whether this plan scans the given index.- Specified by:
hasIndexScan
in interfaceQueryPlan<FDBQueriedRecord<Message>>
- 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 public Set<String> getUsedIndexes()
Description copied from interface:QueryPlan
Returns a set of names of the indexes used by this plan (and its sub-plans).- Specified by:
getUsedIndexes
in interfaceQueryPlan<FDBQueriedRecord<Message>>
- Returns:
- an set of indexes used by this plan
-
maxCardinality
public int maxCardinality(@Nonnull RecordMetaData metaData)
Description copied from interface:QueryPlan
Indicates how many records this plan could possibly return.- Specified by:
maxCardinality
in interfaceQueryPlan<FDBQueriedRecord<Message>>
- Parameters:
metaData
- meta-data to use to determine things like index uniqueness- Returns:
- the maximum number of records or
QueryPlan.UNKNOWN_MAX_CARDINALITY
if not known
-
getAvailableFields
@Nonnull public AvailableFields getAvailableFields()
- Specified by:
getAvailableFields
in interfaceRecordQueryPlan
-
hasLoadBykeys
public boolean hasLoadBykeys()
Description copied from interface:QueryPlan
Indicates whether this plan (or one of its components) loads records by their primary key.- Specified by:
hasLoadBykeys
in interfaceQueryPlan<FDBQueriedRecord<Message>>
- Returns:
true
if this plan (or one of its components) loads records by their primary key
-
getCorrelatedTo
@Nonnull public Set<CorrelationIdentifier> getCorrelatedTo()
Description copied from interface:Correlated
Returns the set ofCorrelationIdentifier
s this entity is correlated to. This means that without a process that binds these correlations to values, theRelationalExpression
(or others that implement this interface) cannot even in principle produce a meaningful result. As often times entities that implement this interface use composition and effectively describe trees or DAGs, this method should be the set union of theCorrelationIdentifier
s this object is correlated to as well as all children, constituent parts, etc.- Specified by:
getCorrelatedTo
in interfaceCorrelated<RelationalExpression>
- Returns:
- the set of
CorrelationIdentifier
s this entity is correlated to
-
rebase
@Nonnull public RecordQueryCoveringIndexPlan rebase(@Nonnull AliasMap translationMap)
Description copied from interface:Correlated
Rebases this and all other objects this objects is composed of using a given translation map.- Specified by:
rebase
in interfaceCorrelated<RelationalExpression>
- Parameters:
translationMap
- a map defining a translation fromCorrelationIdentifier
sids
toCorrelationIdentifier
sids'
. After the rebase, every correlation to anid
containedids
that is contained or referred to directly or indirectly bythis
must have been transformed to use the mapped counterpart ofid
id'
inids'
. IDs not contained in the translation map must remain unmodified by the rebase operation.- Returns:
- a new entity that has been rebased
-
equalsWithoutChildren
@Nonnull public boolean equalsWithoutChildren(@Nonnull RelationalExpression otherExpression, @Nonnull AliasMap equivalencesMap)
- Specified by:
equalsWithoutChildren
in interfaceRelationalExpression
-
hashCodeWithoutChildren
public int hashCodeWithoutChildren()
- Specified by:
hashCodeWithoutChildren
in interfaceRelationalExpression
-
logPlanStructure
public void logPlanStructure(StoreTimer timer)
Description copied from interface:QueryPlan
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).- Specified by:
logPlanStructure
in interfaceQueryPlan<FDBQueriedRecord<Message>>
- Parameters:
timer
- the counters to increment
-
getComplexity
public int getComplexity()
Description copied from interface:QueryPlan
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).- Specified by:
getComplexity
in interfaceQueryPlan<FDBQueriedRecord<Message>>
- Returns:
- the complexity of this plan
-
planHash
public int planHash(@Nonnull PlanHashable.PlanHashKind hashKind)
Description copied from interface:PlanHashable
Return a hash similar tohashCode
, but with the additional guarantee that is is stable across JVMs.- Specified by:
planHash
in interfacePlanHashable
- Parameters:
hashKind
- the "kind" of hash to calculate. Each kind of hash has a particular logic with regards to included and excluded items.- Returns:
- a stable hash code
-
getQuantifiers
@Nonnull public List<? extends Quantifier> getQuantifiers()
Description copied from interface:RelationalExpression
Return an iterator of references to the children of this planner expression. The iterators returned by different calls are guaranteed to be independent (i.e., advancing one will not advance another). However, they might point to the same object, as whenCollections.emptyIterator()
is returned. The returned iterator should be treated as an immutable object and may throw an exception ifIterator.remove()
is called. The iterator must return its elements in a consistent order.- Specified by:
getQuantifiers
in interfaceRecordQueryPlanWithNoChildren
- Specified by:
getQuantifiers
in interfaceRelationalExpression
- Returns:
- an iterator of references to the children of this planner expression
-
rewritePlannerGraph
@Nonnull public PlannerGraph rewritePlannerGraph(@Nonnull List<? extends PlannerGraph> childGraphs)
Description copied from interface:PlannerGraphRewritable
Method to rewrite the planner graph.- Specified by:
rewritePlannerGraph
in interfacePlannerGraphRewritable
- Parameters:
childGraphs
- planner graphs of children expression that already have been computed- Returns:
- a new planner graph that can combine the
childGraph
s in a meaningful way. Note that there is no obligation to use thechildGraph
s at all, this method can create a new independent planner graph completely from scratch.
-
-