Class RecordQueryScanPlan
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.plans.RecordQueryScanPlan
-
- All Implemented Interfaces:
PlanHashable
,QueryPlan<FDBQueriedRecord<Message>>
,RecordQueryPlan
,RecordQueryPlanWithComparisons
,RecordQueryPlanWithNoChildren
,Bindable
,Correlated<RelationalExpression>
,PlannerGraphRewritable
,RelationalExpression
@API(INTERNAL) public class RecordQueryScanPlan extends Object implements RecordQueryPlanWithNoChildren, RecordQueryPlanWithComparisons, PlannerGraphRewritable
A query plan that scans records directly from the main tree within a range of primary keys.
-
-
Constructor Summary
Constructors Constructor Description RecordQueryScanPlan(ScanComparisons comparisons, boolean reverse)
Overloaded constructor.RecordQueryScanPlan(Set<String> recordTypes, ScanComparisons comparisons, boolean reverse)
Overloaded constructor.
-
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()
ScanComparisons
getComparisons()
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.Set<String>
getRecordTypes()
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.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
planHash()
Return a hash similar tohashCode
, but with the additional guarantee that is is stable across JVMs.RecordQueryScanPlan
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)
Rewrite the planner graph for better visualization of a query scan plan.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.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, getQuantifiers
-
Methods inherited from interface com.apple.foundationdb.record.query.plan.temp.RelationalExpression
acceptPropertyVisitor, bindTo, canCorrelate, semanticEquals, semanticEquals, semanticHashCode, show
-
-
-
-
Constructor Detail
-
RecordQueryScanPlan
public RecordQueryScanPlan(@Nonnull ScanComparisons comparisons, boolean reverse)
Overloaded constructor. Use the overloaded constructorRecordQueryScanPlan(Set, ScanComparisons, boolean)
to also pass in a set of record types.- Parameters:
comparisons
- comparisons to be applied by the operatorreverse
- indicator whether this scan is reverse
-
RecordQueryScanPlan
public RecordQueryScanPlan(@Nullable Set<String> recordTypes, @Nonnull ScanComparisons comparisons, boolean reverse)
Overloaded constructor.- Parameters:
recordTypes
- a super set of record types of the records that this scan operator can producecomparisons
- comparisons to be applied by the operatorreverse
- indicator whether this scan is reverse
-
-
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
-
getComparisons
@Nonnull public ScanComparisons getComparisons()
- Specified by:
getComparisons
in interfaceRecordQueryPlanWithComparisons
-
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
-
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 RecordQueryScanPlan 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
public boolean equalsWithoutChildren(@Nonnull RelationalExpression otherExpression, @Nonnull AliasMap equivalencesMap)
- Specified by:
equalsWithoutChildren
in interfaceRelationalExpression
-
hashCodeWithoutChildren
public int hashCodeWithoutChildren()
- Specified by:
hashCodeWithoutChildren
in interfaceRelationalExpression
-
planHash
public int planHash()
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
- Returns:
- a stable hash code
-
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
-
rewritePlannerGraph
@Nonnull public PlannerGraph rewritePlannerGraph(@Nonnull List<? extends PlannerGraph> childGraphs)
Rewrite the planner graph for better visualization of a query scan plan.- Specified by:
rewritePlannerGraph
in interfacePlannerGraphRewritable
- Parameters:
childGraphs
- planner graphs of children expression that already have been computed- Returns:
- the rewritten planner graph that models scanned storage as a separate node that is connected to the actual scan plan node.
-
-