Interface PlannerRuleCall
-
- All Known Implementing Classes:
CascadesRuleCall
@API(EXPERIMENTAL) public interface PlannerRuleCall
APlannerRuleCall
is a context object that supports a single application of a rule to a particular expression. It stores and provides convenient access to various context related to the transformation, such as any bindings, access to thePlanContext
, etc. APlannerRuleCall
is passed to every rule'sPlannerRule.onMatch(PlannerRuleCall)
method. Additionally, the rule call implementation is responsible for registering any new expressions generated by the rule via theyield(ExpressionRef)
method. This registration process includes updating any planner data structures to include the new expression. In general, each planner will have an associated implementation ofPlannerRuleCall
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <U extends Bindable>
Uget(ExpressionMatcher<U> key)
Return the bindable that is bound to the given key.Quantifiers.AliasResolver
getAliasResolver()
Returns the alias resolver that is currently in use and maintained by the planner.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 RelationalExpression>
ExpressionRef<U>ref(U expression)
Wrap the given planner expression in an implementation ofExpressionRef
suitable for the planner associated with this rule.void
yield(ExpressionRef<? extends RelationalExpression> expression)
Notify the planner's data structures that the new expression contained inexpression
has been produced by the rule.void
yieldPartialMatch(AliasMap boundAliasMap, MatchCandidate matchCandidate, RelationalExpression queryExpression, ExpressionRef<? extends RelationalExpression> candidateRef, MatchInfo matchInfo)
Notify the planner's data structures that a new partial match has been produced by the rule.
-
-
-
Method Detail
-
getAliasResolver
@Nonnull Quantifiers.AliasResolver getAliasResolver()
Returns the alias resolver that is currently in use and maintained by the planner.- Returns:
- the alias resolver
-
getBindings
@Nonnull 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. This method should be implemented by rule call implementations, but users of the rule should usually access these viaget(ExpressionMatcher)
.- Returns:
- the map of bindings that the rule's matcher expression produced
-
getContext
@Nonnull PlanContext getContext()
Get the planning context with metadata that might be relevant to the planner, such as the list of available indexes.- Returns:
- a
PlanContext
object with various metadata that could affect planning
-
get
@Nonnull default <U extends Bindable> U get(@Nonnull ExpressionMatcher<U> key)
Return the bindable that is bound to the given key.- Type Parameters:
U
- the requested return type- Parameters:
key
- the binding from the rule's matcher expression- Returns:
- the bindable bound to
name
in the rule's matcher expression - Throws:
NoSuchElementException
- whenkey
is not a valid binding, or is not bound to a bindable
-
yield
void yield(@Nonnull ExpressionRef<? extends RelationalExpression> expression)
Notify the planner's data structures that the new expression contained inexpression
has been produced by the rule. This method may be called zero or more times by the rule'sonMatch()
method.- Parameters:
expression
- the expression produced by the rule
-
yieldPartialMatch
void yieldPartialMatch(@Nonnull AliasMap boundAliasMap, @Nonnull MatchCandidate matchCandidate, @Nonnull RelationalExpression queryExpression, @Nonnull ExpressionRef<? extends RelationalExpression> candidateRef, @Nonnull MatchInfo matchInfo)
Notify the planner's data structures that a new partial match has been produced by the rule. This method may be called zero or more times by the rule'sonMatch()
method.- Parameters:
boundAliasMap
- the alias map of bound correlated identifiers between query and candidatematchCandidate
- the match candidatequeryExpression
- the query expressioncandidateRef
- the matching reference on the candidate sidematchInfo
- an auxiliary structure to keep additional information about the match
-
ref
<U extends RelationalExpression> ExpressionRef<U> ref(U expression)
Wrap the given planner expression in an implementation ofExpressionRef
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.- Type Parameters:
U
- the type of the planner expression- Parameters:
expression
- the planner expression to wrap in a reference type- Returns:
expression
wrapped in a reference
-
-