public class IndexEntrySourceScanExpression extends Object implements RelationalPlannerExpression
RecordQueryIndexPlan
that represents
a partially-implemented index scan. The primary difference between the two is that a RecordQueryIndexPlan
requires a fully formed ScanComparisons
, which does not track
which comparisons belong to which parts of the index's key expression. In contrast, this logical index scan has a
KeyExpressionComparisons
which explicitly tracks that information. Except for the final "implementation"
rules, a planner rule should generally prefer to produce and consume IndexEntrySourceScanExpression
s so that
important information about the index key expression is retained.Constructor and Description |
---|
IndexEntrySourceScanExpression(IndexEntrySource indexEntrySource,
IndexScanType scanType,
KeyExpressionComparisons comparisons,
boolean reverse) |
Modifier and Type | Method and Description |
---|---|
ExpressionRef<RelationalPlannerExpression> |
asNestedWith(NestedContext nestedContext,
ExpressionRef<RelationalPlannerExpression> thisRef)
Produce an exactly equivalent version of the
PlannerExpression tree rooted at this
RelationalPlannerExpression as if all operations were nested inside the given NestedContext . |
ExpressionRef<RelationalPlannerExpression> |
asUnnestedWith(NestedContext nestedContext,
ExpressionRef<RelationalPlannerExpression> thisRef)
Produce an exactly equivalent version of the
PlannerExpression tree rooted at this
RelationalPlannerExpression with all operations placed inside the field given by the NestedContext . |
boolean |
equals(Object o) |
boolean |
equalsWithoutChildren(PlannerExpression otherExpression) |
KeyExpressionComparisons |
getComparisons() |
IndexEntrySource |
getIndexEntrySource() |
String |
getIndexName() |
Iterator<? extends ExpressionRef<? extends PlannerExpression>> |
getPlannerExpressionChildren()
Return an iterator of references to the children of this planner expression.
|
IndexScanType |
getScanType() |
int |
hashCode() |
boolean |
isReverse() |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
fromRecordQuery
acceptPropertyVisitor, bindTo
public IndexEntrySourceScanExpression(@Nonnull IndexEntrySource indexEntrySource, @Nonnull IndexScanType scanType, @Nonnull KeyExpressionComparisons comparisons, boolean reverse)
@Nonnull public Iterator<? extends ExpressionRef<? extends PlannerExpression>> getPlannerExpressionChildren()
PlannerExpression
Collections.emptyIterator()
is returned. The returned iterator should
be treated as an immutable object and may throw an exception if Iterator.remove()
is called.
The iterator must return its elements in a consistent order.getPlannerExpressionChildren
in interface PlannerExpression
@Nonnull public IndexEntrySource getIndexEntrySource()
@Nonnull public IndexScanType getScanType()
@Nonnull public KeyExpressionComparisons getComparisons()
public boolean isReverse()
@Nullable public ExpressionRef<RelationalPlannerExpression> asNestedWith(@Nonnull NestedContext nestedContext, @Nonnull ExpressionRef<RelationalPlannerExpression> thisRef)
RelationalPlannerExpression
PlannerExpression
tree rooted at this
RelationalPlannerExpression
as if all operations were nested inside the given NestedContext
. That
is, transform all predicates, index scans, and other operations to the form that they would have if they were
nested within the field given by the parent field of the given nested context. If it is not possible to produce
such an expression, return null
.
With RelationalPlannerExpression.asUnnestedWith(NestedContext, ExpressionRef)
, this method should obey the contract that, for any
expression
and nestedContext
,
expression.asNestedWith(nestedContext, ref).asUnnestedWith(nestedContext, ref)
is either equal to
expression
(according to the equals()
comparison) or null
.
For example, if this expression is a filter on the predicate field("a").matches(field("b).equals(3))
,
with an inner FullUnorderedScanExpression
, and the nestedContext
is built around
field("a")
, then this method would return a reference containing a logical filter on the predicate
field("b").equals(3
) with an inner FullUnorderedScanExpression
.
The thisRef
parameter has two uses. For some implementations of asNestedWith()
, the expression
does not need to be changed, and so it is more efficient to return the containing reference than to build a
new one. Additionally, it is used to generate a reference of the appropriate type using the
ExpressionRef.getNewRefWith(PlannerExpression)
.
asNestedWith
in interface RelationalPlannerExpression
nestedContext
- a context describing the field to use for nestingthisRef
- the reference that contains this relational planner expression@Nullable public ExpressionRef<RelationalPlannerExpression> asUnnestedWith(@Nonnull NestedContext nestedContext, @Nonnull ExpressionRef<RelationalPlannerExpression> thisRef)
RelationalPlannerExpression
PlannerExpression
tree rooted at this
RelationalPlannerExpression
with all operations placed inside the field given by the NestedContext
.
That is, put all predicates, index scans, and other operations within the given nested field. If it is not possible
to produce such an expression, return null
.
With RelationalPlannerExpression.asNestedWith(NestedContext, ExpressionRef)
, this method should obey the contract that, for any
expression
and nestedContext
,
expression.asNestedWith(nestedContext, ref).asUnnestedWith(nestedContext, ref)
is either equal to
expression
(according to the equals()
comparison) or null
.
For example, if this expression is a logical filter on the predicate field("b).equals(3)
, with an inner
FullUnorderedScanExpression
, and the nestedContext
is built around field("a")
, then this
method would return a reference containing a logical filter on the predicate
field("a").matches(field("b").equals(3))
with an inner FullUnorderedScanExpression
.
The thisRef
parameter has two uses. For some implementations of asUnnestedWith()
, the expression
does not need to be changed, and so it is more efficient to return the containing reference than to build a
new one. Additionally, it is used to generate a reference of the appropriate type using the
ExpressionRef.getNewRefWith(PlannerExpression)
.
asUnnestedWith
in interface RelationalPlannerExpression
nestedContext
- a context describing the field to use for unnestingthisRef
- the reference that contains this expressionpublic boolean equalsWithoutChildren(@Nonnull PlannerExpression otherExpression)
equalsWithoutChildren
in interface PlannerExpression