Class ReferenceMatcher<T extends RelationalExpression>
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.temp.matchers.ExpressionMatcher.DefaultMatcher<ExpressionRef<T>>
-
- com.apple.foundationdb.record.query.plan.temp.matchers.ReferenceMatcher<T>
-
- Type Parameters:
T
- type parameter indicating the type of the expression the reference is a container for
- All Implemented Interfaces:
ExpressionMatcher<ExpressionRef<T>>
@API(EXPERIMENTAL) public abstract class ReferenceMatcher<T extends RelationalExpression> extends ExpressionMatcher.DefaultMatcher<ExpressionRef<T>> 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 aReferenceMatcher
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 theReferenceMatcher
has a type parameter, it cannot statically verify that the type ofRelationalExpression
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 ofPlannerExpression
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 byRelationalExpression.getQuantifiers()
. For example, it would be safe to use aReferenceMatcher<QueryComponent>
to match against the second planner expression child of aRecordQueryFilterPlan
because that child is necessarily aQueryComponent
; 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, thePlannerBindings
will throw aClassCastException
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.apple.foundationdb.record.query.plan.temp.matchers.ExpressionMatcher
ExpressionMatcher.DefaultMatcher<T extends Bindable>
-
-
Constructor Summary
Constructors Constructor Description ReferenceMatcher()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T extends RelationalExpression>
ReferenceMatcher<T>allOf(ExpressionMatcher<T> membersMatcher)
Return a newReferenceMatcher
instance.static <T extends RelationalExpression>
ReferenceMatcher<T>anyOf(ExpressionMatcher<T> membersMatcher)
Return a newReferenceMatcher
instance.static ReferenceMatcher<? extends RelationalExpression>
anyRef()
Return a newReferenceMatcher
instance.Class<? extends Bindable>
getRootClass()
Get a class or interface extendingRelationalExpression
that is a super class of every planner expression that this matcher can match.-
Methods inherited from class com.apple.foundationdb.record.query.plan.temp.matchers.ExpressionMatcher.DefaultMatcher
matchWith, matchWith, matchWith, matchWith, matchWith, matchWith
-
-
-
-
Method Detail
-
getRootClass
@Nonnull public Class<? extends Bindable> getRootClass()
Description copied from interface:ExpressionMatcher
Get a class or interface extendingRelationalExpression
that is a super class of every planner expression that this matcher can match. Ideally, it should be the lowest such class but it may not be. A planner will generally use this method to quickly determine a set of rules that could match an expression, without considering each rule and trying to apply it. A good implementation of this method helps the planner match rules efficiently.- Specified by:
getRootClass
in interfaceExpressionMatcher<T extends RelationalExpression>
- Overrides:
getRootClass
in classExpressionMatcher.DefaultMatcher<ExpressionRef<T extends RelationalExpression>>
- Returns:
- a class object for a class that is a super class of every planner expression this matcher can match
-
anyRef
public static ReferenceMatcher<? extends RelationalExpression> anyRef()
Return a newReferenceMatcher
instance. The returned matcher is guaranteed to be distinct (according to pointer comparison) from the matchers returned by other calls toanyRef()
, so that multiple such matchers may be used in a singlePlannerBindings
object.- Returns:
- a new, distinct matcher that matches to any reference
-
anyOf
public static <T extends RelationalExpression> ReferenceMatcher<T> anyOf(@Nonnull ExpressionMatcher<T> membersMatcher)
Return a newReferenceMatcher
instance. The returned matcher is guaranteed to be distinct (according to pointer comparison) from the matchers returned by other calls toanyRef()
, so that multiple such matchers may be used in a singlePlannerBindings
object.- Type Parameters:
T
- type parameter indicating the type of the expression the reference is a container for- Parameters:
membersMatcher
- a matcher that is applied to the members of this reference- Returns:
- a new, distinct matcher that matches to the cross product of references and their respective members matching
the
membersMatcher
.
-
allOf
public static <T extends RelationalExpression> ReferenceMatcher<T> allOf(@Nonnull ExpressionMatcher<T> membersMatcher)
Return a newReferenceMatcher
instance. The returned matcher is guaranteed to be distinct (according to pointer comparison) from the matchers returned by other calls. Moreover, the matcher is strongly typed to the same typeT
of themembersMatcher
that is passed in.- Type Parameters:
T
- type parameter indicating the type of the expression the reference is a container for- Parameters:
membersMatcher
- a matcher that is applied to the members of this reference- Returns:
- a new, distinct matcher that matches to the cross product of references and their respective members matching
the
membersMatcher
.
-
-