Class Quantifier
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.temp.Quantifier
-
- All Implemented Interfaces:
Bindable
- Direct Known Subclasses:
Quantifier.Existential
,Quantifier.ForEach
,Quantifier.Physical
public abstract class Quantifier extends Object implements Bindable
Models the concept of quantification.A quantifier describes the data flow between the output of one
RelationalExpression
R
and the consumption of that data by anotherRelationalExpression
S
.S
is said to own the quantifier, while the quantifier is said to range overR
. Quantifiers come in very few but very distinct flavors. All flavors are implemented by static inner final classes in order to emulate a sealed trait.Quantifiers separate what it means to be producing versus consuming items. The expression a quantifier ranges over produces records, the quantifier flows information (in a manner determined by the flavor) that is consumed by the expression containing or owning the quantifier. That expression can consume the data in a way independent of how the data was produced in the first place.
A quantifier works closely with the expression that owns it. Depending on the semantics of the owning expression it becomes possible to model correlations. For example, in a logical join expression the quantifier can provide a binding of the item being currently consumed by the join's outer to other (inner) parts of the data flow that are also rooted at the owning (join) expression.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Quantifier.Existential
A quantifier that conceptually flows exactly one item containing a boolean to the owning expression indicating whether the subgraph that the quantifier ranges over produced a non-empty or an empty result.static class
Quantifier.ForEach
A quantifier that conceptually flows one item at a time from the expression it ranges over to the owning expression.static class
Quantifier.Physical
Physical quantifier.
-
Constructor Summary
Constructors Constructor Description Quantifier()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <U> U
acceptPropertyVisitor(PlannerProperty<U> visitor)
Allow the computation ofPlannerProperty
s across the quantifiers in the data flow graph.Stream<PlannerBindings>
bindTo(ExpressionMatcher<? extends Bindable> matcher)
Attempt to match the matcher to this bindable object.boolean
equals(Object o)
static Quantifier.Existential
existential(ExpressionRef<? extends RelationalExpression> rangesOver)
Factory method to create an existential quantifier over a given expression reference containing relational expressions.static Quantifier.ForEach
forEach(ExpressionRef<? extends RelationalExpression> rangesOver)
Factory method to create a for-each quantifier over a given expression reference containing relational expressions.abstract ExpressionRef<? extends RelationalExpression>
getRangesOver()
Return the reference that the quantifier ranges over.abstract String
getShorthand()
Return a short hand string for the quantifier.int
hashCode()
static Quantifier.Physical
physical(RecordQueryPlan rangesOverPlan)
Factory method to create a physical quantifier over newly created expression reference containing the given record plan.static Quantifier.Physical
physical(ExpressionRef<? extends RecordQueryPlan> rangesOver)
Factory method to create a physical quantifier over a given expression reference containing query plans.
-
-
-
Method Detail
-
forEach
@Nonnull public static Quantifier.ForEach forEach(ExpressionRef<? extends RelationalExpression> rangesOver)
Factory method to create a for-each quantifier over a given expression reference containing relational expressions.- Parameters:
rangesOver
- expression reference toRelationalExpression
s- Returns:
- a for-each quantifier ranging over the given expression reference
-
existential
@Nonnull public static Quantifier.Existential existential(@Nonnull ExpressionRef<? extends RelationalExpression> rangesOver)
Factory method to create an existential quantifier over a given expression reference containing relational expressions.- Parameters:
rangesOver
- expression reference toRelationalExpression
s- Returns:
- a for-each quantifier ranging over the given expression reference
-
physical
@Nonnull public static Quantifier.Physical physical(@Nonnull ExpressionRef<? extends RecordQueryPlan> rangesOver)
Factory method to create a physical quantifier over a given expression reference containing query plans.- Parameters:
rangesOver
- expression reference toRecordQueryPlan
s- Returns:
- a physical quantifier ranging over the given reference
-
physical
@Nonnull public static Quantifier.Physical physical(@Nonnull RecordQueryPlan rangesOverPlan)
Factory method to create a physical quantifier over newly created expression reference containing the given record plan.- Parameters:
rangesOverPlan
-RecordQueryPlan
the new quantifier should range over.- Returns:
- a physical quantifier ranging over a new expression reference containing the given expression reference
-
getRangesOver
@Nonnull public abstract ExpressionRef<? extends RelationalExpression> getRangesOver()
Return the reference that the quantifier ranges over.- Returns:
ExpressionRef
this quantifier ranges over
-
getShorthand
@Nonnull public abstract String getShorthand()
Return a short hand string for the quantifier. As a quantifier's semantics is usually quite subtle and should not distract from expressions. For example, when a data flow is visualized the returned string should be short.- Returns:
- a short string representing the quantifier.
-
bindTo
@Nonnull public Stream<PlannerBindings> bindTo(@Nonnull ExpressionMatcher<? extends Bindable> matcher)
Description copied from interface:Bindable
Attempt to match the matcher to this bindable object.
-
acceptPropertyVisitor
@Nullable public <U> U acceptPropertyVisitor(@Nonnull PlannerProperty<U> visitor)
Allow the computation ofPlannerProperty
s across the quantifiers in the data flow graph.- Type Parameters:
U
- the type of the property being computed- Parameters:
visitor
- the planner property that is being computed- Returns:
- the property
-
-