Class TypeMatcher<T extends Bindable>
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.temp.matchers.TypeMatcher<T>
-
- Type Parameters:
T
- the planner expression type that this matcher binds to
- All Implemented Interfaces:
ExpressionMatcher<T>
- Direct Known Subclasses:
MatchPartitionMatcher
,PartialMatchMatcher
,QuantifierMatcher
,TypeWithPredicateMatcher
@API(EXPERIMENTAL) public class TypeMatcher<T extends Bindable> extends Object implements ExpressionMatcher<T>
A matcher that is specified by the class of its expression: to match any of several types of expressions, they must all implement a common interface (which itself extendsPlannerExpression
). The bindings produced by this matcher provide access to a single expression only, and allow it to be accessed by the rule.
-
-
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 Modifier Constructor Description protected
TypeMatcher(Class<? extends T> bindableClass, ExpressionChildrenMatcher childrenMatcher)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ExpressionChildrenMatcher
getChildrenMatcher()
Class<? extends Bindable>
getRootClass()
Get a class or interface extendingRelationalExpression
that is a super class of every planner expression that this matcher can match.Stream<PlannerBindings>
matchWith(PlannerBindings outerBindings, ExpressionRef<? extends RelationalExpression> ref, List<? extends Bindable> children)
Attempt to match this matcher against the given expression reference.Stream<PlannerBindings>
matchWith(PlannerBindings outerBindings, MatchPartition matchPartition, List<? extends Bindable> children)
Attempt to match this matcher against the givenMatchPartition
.Stream<PlannerBindings>
matchWith(PlannerBindings outerBindings, PartialMatch partialMatch, List<? extends Bindable> children)
Attempt to match this matcher against the givenPartialMatch
.Stream<PlannerBindings>
matchWith(PlannerBindings outerBindings, Quantifier quantifier, List<? extends Bindable> children)
Attempt to match this matcher against the givenQuantifier
.Stream<PlannerBindings>
matchWith(PlannerBindings outerBindings, RelationalExpression expression, List<? extends Bindable> children)
Attempt to match this matcher against the givenExpressionMatcher
.Stream<PlannerBindings>
matchWith(PlannerBindings outerBindings, QueryPredicate predicate, List<? extends Bindable> children)
Attempt to match this matcher against the givenQueryPredicate
.static <U extends Bindable>
TypeMatcher<U>of(Class<? extends U> expressionClass)
static <U extends Bindable>
TypeMatcher<U>of(Class<? extends U> expressionClass, ExpressionChildrenMatcher childrenMatcher)
static <U extends Bindable>
TypeMatcher<U>of(Class<? extends U> expressionClass, ExpressionMatcher<? extends Bindable>... children)
-
-
-
Constructor Detail
-
TypeMatcher
protected TypeMatcher(@Nonnull Class<? extends T> bindableClass, @Nonnull ExpressionChildrenMatcher childrenMatcher)
-
-
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 Bindable>
- Returns:
- a class object for a class that is a super class of every planner expression this matcher can match
-
getChildrenMatcher
@Nonnull public ExpressionChildrenMatcher getChildrenMatcher()
-
of
public static <U extends Bindable> TypeMatcher<U> of(@Nonnull Class<? extends U> expressionClass)
-
of
@SafeVarargs public static <U extends Bindable> TypeMatcher<U> of(@Nonnull Class<? extends U> expressionClass, @Nonnull ExpressionMatcher<? extends Bindable>... children)
-
of
public static <U extends Bindable> TypeMatcher<U> of(@Nonnull Class<? extends U> expressionClass, @Nonnull ExpressionChildrenMatcher childrenMatcher)
-
matchWith
@Nonnull public Stream<PlannerBindings> matchWith(@Nonnull PlannerBindings outerBindings, @Nonnull ExpressionRef<? extends RelationalExpression> ref, @Nonnull List<? extends Bindable> children)
Description copied from interface:ExpressionMatcher
Attempt to match this matcher against the given expression reference. Note that implementations ofmatchWith()
should only attempt to match the given root with this planner expression or attempt to access the members of the given reference.- Specified by:
matchWith
in interfaceExpressionMatcher<T extends Bindable>
- Parameters:
outerBindings
- preexisting bindings to be used by the matcherref
- a reference to match withchildren
- the conceptual children ofref
, i.e. the memmbers of the group reference.- Returns:
- a stream of
PlannerBindings
containing the matched bindings, or an empty stream is no match was found
-
matchWith
@Nonnull public Stream<PlannerBindings> matchWith(@Nonnull PlannerBindings outerBindings, @Nonnull RelationalExpression expression, @Nonnull List<? extends Bindable> children)
Description copied from interface:ExpressionMatcher
Attempt to match this matcher against the givenExpressionMatcher
. Note that implementations ofmatchWith()
should only attempt to match the given root with this planner expression.- Specified by:
matchWith
in interfaceExpressionMatcher<T extends Bindable>
- Parameters:
outerBindings
- preexisting bindings to be used by the matcherexpression
- a planner expression to match withchildren
- the conceptual children ofexpression
- Returns:
- a stream of
PlannerBindings
containing the matched bindings, or an empty stream is no match was found
-
matchWith
@Nonnull public Stream<PlannerBindings> matchWith(@Nonnull PlannerBindings outerBindings, @Nonnull QueryPredicate predicate, @Nonnull List<? extends Bindable> children)
Description copied from interface:ExpressionMatcher
Attempt to match this matcher against the givenQueryPredicate
. Note that implementations ofmatchWith()
should only attempt to match the given root with this planner expression.- Specified by:
matchWith
in interfaceExpressionMatcher<T extends Bindable>
- Parameters:
outerBindings
- preexisting bindings to be used by the matcherpredicate
- a predicate to match withchildren
- the conceptual children ofpredicate
- Returns:
- a stream of
PlannerBindings
containing the matched bindings, or an empty stream is no match was found
-
matchWith
@Nonnull public Stream<PlannerBindings> matchWith(@Nonnull PlannerBindings outerBindings, @Nonnull Quantifier quantifier, @Nonnull List<? extends Bindable> children)
Description copied from interface:ExpressionMatcher
Attempt to match this matcher against the givenQuantifier
. Note that implementations ofmatchWith()
should only attempt to match the given root with this planner expression.- Specified by:
matchWith
in interfaceExpressionMatcher<T extends Bindable>
- Parameters:
outerBindings
- preexisting bindings to be used by the matcherquantifier
- a quantifier to match withchildren
- the conceptual children ofquantifier
- Returns:
- a stream of
PlannerBindings
containing the matched bindings, or an empty stream is no match was found
-
matchWith
@Nonnull public Stream<PlannerBindings> matchWith(@Nonnull PlannerBindings outerBindings, @Nonnull PartialMatch partialMatch, @Nonnull List<? extends Bindable> children)
Description copied from interface:ExpressionMatcher
Attempt to match this matcher against the givenPartialMatch
. Note that implementations ofmatchWith()
should only attempt to match the given root with this planner expression.- Specified by:
matchWith
in interfaceExpressionMatcher<T extends Bindable>
- Parameters:
outerBindings
- preexisting bindings to be used by the matcherpartialMatch
- a partial match to match withchildren
- the conceptual children ofpredicate
- Returns:
- a stream of
PlannerBindings
containing the matched bindings, or an empty stream is no match was found
-
matchWith
@Nonnull public Stream<PlannerBindings> matchWith(@Nonnull PlannerBindings outerBindings, @Nonnull MatchPartition matchPartition, @Nonnull List<? extends Bindable> children)
Description copied from interface:ExpressionMatcher
Attempt to match this matcher against the givenMatchPartition
. Note that implementations ofmatchWith()
should only attempt to match the given root with this planner expression.- Specified by:
matchWith
in interfaceExpressionMatcher<T extends Bindable>
- Parameters:
outerBindings
- preexisting bindings to be used by the matchermatchPartition
- to match withchildren
- the conceptual children ofpredicate
- Returns:
- a stream of
PlannerBindings
containing the matched bindings, or an empty stream is no match was found
-
-