Class ReferenceMatcher<T extends RelationalExpression>

  • Type Parameters:
    T - the type of planner expression that this matcher will always bind to
    All Implemented Interfaces:
    ExpressionMatcher<ExpressionRef<T>>

    @API(EXPERIMENTAL)
    public class ReferenceMatcher<T extends RelationalExpression>
    extends Object
    implements ExpressionMatcher<ExpressionRef<T>>
    An expression matcher that matches against any reference at all. It is frequently used by rules that want to capture everything behind a reference without regard for its content. The bindings generated by a ReferenceMatcher do not provide any access to what was matched. However, the references from the binding can be used when constructing new planner expressions to yield to the planner, which is especially efficient when the references are groups. Although the ReferenceMatcher has a type parameter, it cannot statically verify that the type of RelationalExpression behind a reference actually matches its type parameter, because of type erasure. It is up to the programmer to verify that the type parameter is general enough to cover every possible type of PlannerExpression that might be behind any reference that it could be matched to. In general, the programmer will be certain that a reference would contain a particular type because an expression of a certain type is always found in a particular position of the iterator returned by RelationalExpression.getQuantifiers(). For example, it would be safe to use a ReferenceMatcher<QueryComponent> to match against the second planner expression child of a RecordQueryFilterPlan because that child is necessarily a QueryComponent; note that there is no way for the type system to know that, so the programmer must track such information when writing rules. If the wrong type is used for the type parameter, the PlannerBindings will throw a ClassCastException.