public class RelationalGroupRefHolder extends Object implements RelationalExpressionWithChildren
FixedCollectionExpressionRef
which contains a fixed
number of possible implementations of a relational planner expression. For example, the child reference might have
a member for each of the indexes that could implement a part of a filter. Rules should be extremely careful
when binding to or otherwise manipulating a RelationalGroupRefHolder
as anything other than a reference to a
relational planner expression; in general, rules other than the
PickFromPossibilitiesRule
should not bind to it at all.
A RelationalGroupRefHolder
acts as a special marker or "barrier" for a rewrite-style planner that usually
only considers a single expression at once but needs the ability to compare multiple planner expressions in a limited
sense. For example, if several indexes could implement part of a filter, we can try each of them and pick the one
that satisfies the greatest number of filters. The group reference holder exists primarily to prevent rules that are
not aware of the unusual semantics from binding through a FixedCollectionExpressionRef
, which can create
a variety of complex problems that a rewrite planner is not equipped to handle and which would require a full
Cascades-style planner to perform efficiently.
Unlike a Cascades-style Memo data structure, the RelationalGroupRefHolder
does not attempt to memoize shared
results across different parts of a planner expression tree. As a result, care should be taken to minimize the number
of members in a collection reference. For an example of this, see the implementation of the
FindPossibleIndexForAndComponentRule
.
FixedCollectionExpressionRef
Constructor and Description |
---|
RelationalGroupRefHolder(Collection<RelationalPlannerExpression> groupMembers) |
Modifier and Type | Method and Description |
---|---|
FixedCollectionExpressionRef<RelationalPlannerExpression> |
getInnerGroup() |
Iterator<? extends ExpressionRef<? extends PlannerExpression>> |
getPlannerExpressionChildren()
Return an iterator of references to the children of this planner expression.
|
int |
getRelationalChildCount() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
fromRecordQuery
acceptPropertyVisitor, bindTo
public RelationalGroupRefHolder(@Nonnull Collection<RelationalPlannerExpression> groupMembers)
@Nonnull public FixedCollectionExpressionRef<RelationalPlannerExpression> getInnerGroup()
@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
public int getRelationalChildCount()
getRelationalChildCount
in interface RelationalExpressionWithChildren