Interface ExpressionRef<T extends RelationalExpression>

    • Method Detail

      • insert

        boolean insert​(@Nonnull
                       T newValue)
        Insert a new expression into this reference.
        Parameters:
        newValue - the value to be inserted
        Returns:
        true if the value was not already part of the reference and was inserted, false if the given value was already contained in the reference and was therefore not inserted.
      • get

        @Nonnull
        T get()
        Return the expression contained in this reference. If the reference does not support getting its expresssion (for example, because it holds more than one expression, or none at all), this should throw an exception.
        Returns:
        the expression contained in this reference
        Throws:
        ExpressionRef.UngettableReferenceException - if the reference does not support retrieving its expression
      • bindTo

        @Nonnull
        default Stream<PlannerBindings> bindTo​(@Nonnull
                                               PlannerBindings outerBindings,
                                               @Nonnull
                                               ExpressionMatcher<? extends Bindable> matcher)
        Try to bind the given matcher to this reference. It should not try to match to the members of the reference; if the given matcher needs to match to a RelationalExpression rather than an ExpressionRef, it will call bindWithin(PlannerBindings, ExpressionMatcher) instead.

        Binding to references can be a bit subtle: some matchers (such as ReferenceMatcher) can bind to references directly while others (such as TypeMatcher) can't, since they need access to the underlying operator which might not even be well defined. This method implements binding to the reference, rather than to its member(s).

        Specified by:
        bindTo in interface Bindable
        Parameters:
        outerBindings - preexisting bindings to be used by the matcher
        matcher - a matcher to match with
        Returns:
        a stream of bindings if the match succeeded or an empty stream if it failed
      • bindWithin

        @Nonnull
        Stream<PlannerBindings> bindWithin​(@Nonnull
                                           PlannerBindings outerBindings,
                                           @Nonnull
                                           ExpressionMatcher<? extends Bindable> matcher)
        Try to bind the given matcher to the members of this reference. If this reference has more than one member, it should try to match to any of them and produce a stream of bindings covering all possible combinations. If possible, this should be done in a lazy fashion using the Stream API, so as to minimize unnecessary work.
        Parameters:
        outerBindings - preexisting bindings
        matcher - an expression matcher to match the member(s) of this reference with
        Returns:
        a stream of bindings if the match succeeded or an empty stream if it failed
      • getMatchCandidates

        @Nonnull
        Set<MatchCandidate> getMatchCandidates()
        Return all match candidates that partially match this reference. This set must be a subset of all MatchCandidates in the PlanContext during planning. Note that it is possible that a particular match candidate matches this reference more than once.
        Returns:
        a set of match candidates that partially match this reference.
      • getPartialMatchesForExpression

        @Nonnull
        Collection<PartialMatch> getPartialMatchesForExpression​(@Nonnull
                                                                RelationalExpression expression)
        Return all partial matches that match a given expression. This method is agnostic of the MatchCandidate that created the partial match.
        Parameters:
        expression - expression to return partial matches for. This expression has to be a member of this reference
        Returns:
        a collection of partial matches that matches the give expression to some candidate
      • getPartialMatchesForCandidate

        @Nonnull
        Set<PartialMatch> getPartialMatchesForCandidate​(MatchCandidate candidate)
        Return all partial matches for the MatchCandidate passed in.
        Parameters:
        candidate - match candidate
        Returns:
        a set of partial matches for candidate
      • addPartialMatchForCandidate

        boolean addPartialMatchForCandidate​(MatchCandidate candidate,
                                            PartialMatch partialMatch)
        Add the PartialMatch passed in to this reference for the MatchCandidate passed in.
        Parameters:
        candidate - match candidate this partial match relates to
        partialMatch - a new partial match.
        Returns:
        true if this call added a new partial, false if the partial match passed in was already contained in this reference