@API(value=EXPERIMENTAL) public class RewriteRuleCall extends Object implements PlannerRuleCall
RewritePlanner
.
When a new expression is yieled by the rule's PlannerRule.onMatch(com.apple.foundationdb.record.query.plan.temp.PlannerRuleCall)
method, the rule call substitutes the
existing contents of the root with the yielded expression.Modifier and Type | Method and Description |
---|---|
PlannerBindings |
getBindings()
Return the map of bindings that this rule's matcher expression produced, which includes (by contract) all of the
bindings specified by the rule associated with this call.
|
PlanContext |
getContext()
Get the planning context with metadata that might be relevant to the planner, such as the list of available
indexes.
|
<U extends PlannerExpression> |
ref(U expression)
Wrap the given planner expression in an implementation of
ExpressionRef suitable for the planner associated
with this rule. |
PlannerRule.ChangesMade |
run()
Run this rule call by calling the rule's
PlannerRule.onMatch(PlannerRuleCall) method. |
String |
toString() |
static Stream<RewriteRuleCall> |
tryMatchRule(PlanContext context,
PlannerRule<? extends PlannerExpression> rule,
SingleExpressionRef<PlannerExpression> root)
Attempt to match the given
PlannerRule to the planner expression root . |
void |
yield(ExpressionRef<? extends PlannerExpression> expression)
Replace the expression held by the
root reference with the given expression. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
get
public PlannerRule.ChangesMade run()
PlannerRule.onMatch(PlannerRuleCall)
method.PlannerRule.ChangesMade
that indicates whether the running the rule yielded a new expression@Nonnull public PlannerBindings getBindings()
PlannerRuleCall
PlannerRuleCall.get(ExpressionMatcher)
.getBindings
in interface PlannerRuleCall
@Nonnull public PlanContext getContext()
PlannerRuleCall
getContext
in interface PlannerRuleCall
PlanContext
object with various metadata that could affect planningpublic void yield(@Nonnull ExpressionRef<? extends PlannerExpression> expression)
root
reference with the given expression.yield
in interface PlannerRuleCall
expression
- the expression produced by the rulepublic <U extends PlannerExpression> ExpressionRef<U> ref(U expression)
PlannerRuleCall
ExpressionRef
suitable for the planner associated
with this rule. Different rule call implementations might use different reference types depending on the specifics
of the associated planner.ref
in interface PlannerRuleCall
U
- the type of the planner expressionexpression
- the planner expression to wrap in a reference typeexpression
wrapped in a referencepublic static Stream<RewriteRuleCall> tryMatchRule(@Nonnull PlanContext context, @Nonnull PlannerRule<? extends PlannerExpression> rule, @Nonnull SingleExpressionRef<PlannerExpression> root)
PlannerRule
to the planner expression root
. If the rule's expression
matcher matches root
, create a new RewriteRuleCall
with the given root
and the
given rule, and return it. If the rule's expression matcher does not match root
then return
Optional.empty()
.context
- a plan context with various metadata that could affect planningrule
- a rule to attempt to applyroot
- a single expression reference containing a planner expression to apply the rule toOptional
containing a rewrite rule call if the rule's matcher matched or Optional.empty()
otherwise