Interface PlannerRuleCall

  • All Known Implementing Classes:
    CascadesRuleCall

    @API(EXPERIMENTAL)
    public interface PlannerRuleCall
    A PlannerRuleCall 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 the PlanContext, etc. A PlannerRuleCall is passed to every rule's PlannerRule.onMatch(PlannerRuleCall) method. Additionally, the rule call implementation is responsible for registering any new expressions generated by the rule via the yield(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 of PlannerRuleCall.
    • 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 via get(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 - when key 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 in expression has been produced by the rule. This method may be called zero or more times by the rule's onMatch() 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's onMatch() method.
        Parameters:
        boundAliasMap - the alias map of bound correlated identifiers between query and candidate
        matchCandidate - the match candidate
        queryExpression - the query expression
        candidateRef - the matching reference on the candidate side
        matchInfo - an auxiliary structure to keep additional information about the match
      • ref

        <U extends RelationalExpressionExpressionRef<U> ref​(U expression)
        Wrap the given planner expression in an implementation of 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.
        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