T
- the result type of the property@API(value=EXPERIMENTAL) public interface PlannerProperty<T>
PlannerProperty
is a property that depends on (much of)
the contents of the subtree rooted at the expression on which it is evaluated, rather than just a finite depth set
of paths as a ExpressionMatcher
would. For example,
the sort order and set of record types produced by a
RelationalPlannerExpression
could be a
PlannerProperty
.
To avoid littering PlannerExpression
classes with methods for various properties, properties are implemented
using a variant of the hierarchical visitor pattern the tree of PlannerExpression
s and ExpressionRef
s.
A property can be evaluated against an expression tree by having the visitor traverse the tree. Note that the
"visitLeave()
" methods evaluateAtExpression(com.apple.foundationdb.record.query.plan.temp.PlannerExpression, java.util.List<T>)
and evaluateAtRef(com.apple.foundationdb.record.query.plan.temp.ExpressionRef<? extends com.apple.foundationdb.record.query.plan.temp.PlannerExpression>, java.util.List<T>)
are handed the results of the
visitor evaluated at their children and members respectively. Since most properties are easy to describe as a
recursion with depth one, this makes properties easier to read and write.
Modifier and Type | Method and Description |
---|---|
T |
evaluateAtExpression(PlannerExpression expression,
List<T> childResults)
Evaluate the property at the given expression, using the results of evaluating the property at its children.
|
T |
evaluateAtRef(ExpressionRef<? extends PlannerExpression> ref,
List<T> memberResults)
Evaluate the property at the given reference, using the results of evaluating the property at its members.
|
boolean |
shouldVisit(ExpressionRef<? extends PlannerExpression> ref)
Return whether the property should visit the subtree rooted at the given expression.
|
boolean |
shouldVisit(PlannerExpression expression)
Return whether the property should visit the subtree rooted at the given expression.
|
boolean shouldVisit(@Nonnull PlannerExpression expression)
shouldVisit()
is called on that node.
If shouldVisit()
returns false
, then evaluateAtExpression(PlannerExpression, List)
will
not be called on the given expression.expression
- the planner expression to visittrue
if the children of expression
should be visited and false
if they should not be visitedboolean shouldVisit(@Nonnull ExpressionRef<? extends PlannerExpression> ref)
shouldVisit()
is called on that node.
If shouldVisit()
returns false
, then evaluateAtRef(ExpressionRef, List)
will
not be called on the given expression.ref
- the expression reference to visittrue
if the members of ref
should be visited and false
if they should not be visited@Nonnull T evaluateAtExpression(@Nonnull PlannerExpression expression, @Nonnull List<T> childResults)
evaluateAtExpression()
is called on that node.expression
- the cursor to visitchildResults
- the results of the property evaluated at the children of expression
@Nonnull T evaluateAtRef(@Nonnull ExpressionRef<? extends PlannerExpression> ref, @Nonnull List<T> memberResults)
evaluateAtRef()
is called on that node.ref
- the expression reference to visitmemberResults
- the results of the property evaluated at the members of ref