Interface RelationalExpression
-
- All Superinterfaces:
Bindable
- All Known Subinterfaces:
QueryPlan<T>
,RecordQueryPlan
,RecordQueryPlanWithChild
,RecordQueryPlanWithChildren
,RecordQueryPlanWithComparisons
,RecordQueryPlanWithIndex
,RecordQueryPlanWithNoChildren
,RecordQueryPlanWithRequiredFields
,RelationalExpressionWithChildren
,RelationalExpressionWithPredicate
,TypeFilterExpression
- All Known Implementing Classes:
FullUnorderedScanExpression
,IndexEntrySourceScanExpression
,LogicalDistinctExpression
,LogicalFilterExpression
,LogicalSortExpression
,LogicalTypeFilterExpression
,LogicalUnorderedUnionExpression
,RecordQueryCoveringIndexPlan
,RecordQueryFetchFromPartialRecordPlan
,RecordQueryFilterPlan
,RecordQueryIndexPlan
,RecordQueryInJoinPlan
,RecordQueryInParameterJoinPlan
,RecordQueryIntersectionPlan
,RecordQueryInValuesJoinPlan
,RecordQueryLoadByKeysPlan
,RecordQueryPredicateFilterPlan
,RecordQueryScanPlan
,RecordQueryScoreForRankPlan
,RecordQueryTextIndexPlan
,RecordQueryTypeFilterPlan
,RecordQueryUnionPlan
,RecordQueryUnionPlanBase
,RecordQueryUnorderedDistinctPlan
,RecordQueryUnorderedPrimaryKeyDistinctPlan
,RecordQueryUnorderedUnionPlan
@API(EXPERIMENTAL) public interface RelationalExpression extends Bindable
A relational expression is aRelationalExpression
that represents a stream of records. At all times, the root expression being planned must be relational. This interface acts as a common tag interface forRecordQueryPlan
s, which can actually produce a stream of records, and various logical relational expressions (not yet introduced), which represent an abstract stream of records but can't be executed directly (such as an unimplemented sort). Other planner expressions such asQueryComponent
andKeyExpression
do not represent streams of records. The basic type that represents a part of the planner expression tree. An expression is generally an immutable object with two different kinds of fields: regular Java fields and reference fields. The regular fields represent "node information", which pertains only to this specific node in the tree. In contrast, the reference fields represent this expression's children in the tree, such as its inputs and filter/sort expressions, and are always hidden behind anExpressionRef
. Deciding whether certain fields constitute "node information" (and should therefore be a regular field) or "hierarchical information" (and therefore should not be) is subtle and more of an art than a science. There are two reasonable tests that can help make this decision:- When writing a planner rule to manipulate this field, does it make sense to match it separately or access it as a getter on the matched operator? Will you ever want to match to just this field?
- Should the planner memoize (and therefore optimize) this field separately from its parent?
RecordQueryIndexPlan
has only regular fields, including the index name and the comparisons to use when scanning it. Applying the first rule, it wouldn't really make sense to match the index name or the comparisons being performed on their own: they're what define an index scan, after all! Applying the second rule, they're relatively small immutable objects that don't need to be memoized. In contrast,RecordQueryFilterPlan
has no regular fields. A filter plan has two important fields: theQuery.Component
used for the filter and a child plan that provides input. Both of these might be matched by rules directly, in order to optimize them without regard for the fact that there's a filter. Similarly, they should both be memoized separately, since there might be many possible implementations of each.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <U> U
acceptPropertyVisitor(PlannerProperty<U> visitor)
Apply the given property visitor to this planner expression and its children.default Stream<PlannerBindings>
bindTo(ExpressionMatcher<? extends Bindable> matcher)
Matches a matcher expression to an expression tree rooted at this node, adding to some existing bindings.boolean
equalsWithoutChildren(RelationalExpression otherExpression)
static RelationalExpression
fromRecordQuery(RecordQuery query, PlanContext context)
List<? extends Quantifier>
getQuantifiers()
Return an iterator of references to the children of this planner expression.default String
show(boolean renderSingleGroups)
This is needed for graph integration into IntelliJ as IntelliJ only ever evaluates selfish methods.
-
-
-
Method Detail
-
fromRecordQuery
@Nonnull static RelationalExpression fromRecordQuery(@Nonnull RecordQuery query, @Nonnull PlanContext context)
-
bindTo
@Nonnull default Stream<PlannerBindings> bindTo(@Nonnull ExpressionMatcher<? extends Bindable> matcher)
Matches a matcher expression to an expression tree rooted at this node, adding to some existing bindings.
-
getQuantifiers
@Nonnull List<? extends Quantifier> getQuantifiers()
Return an iterator of references to the children of this planner expression. The iterators returned by different calls are guaranteed to be independent (i.e., advancing one will not advance another). However, they might point to the same object, as whenCollections.emptyIterator()
is returned. The returned iterator should be treated as an immutable object and may throw an exception ifIterator.remove()
is called. The iterator must return its elements in a consistent order.- Returns:
- an iterator of references to the children of this planner expression
-
equalsWithoutChildren
boolean equalsWithoutChildren(@Nonnull RelationalExpression otherExpression)
-
acceptPropertyVisitor
@Nullable default <U> U acceptPropertyVisitor(@Nonnull PlannerProperty<U> visitor)
Apply the given property visitor to this planner expression and its children. Returnsnull
ifPlannerProperty.shouldVisit(RelationalExpression)
called on this expression returnsfalse
.- Type Parameters:
U
- the type of the evaluated property- Parameters:
visitor
- aPlannerProperty
visitor to evaluate- Returns:
- the result of evaluating the property on the subtree rooted at this expression
-
show
@Nonnull default String show(boolean renderSingleGroups)
This is needed for graph integration into IntelliJ as IntelliJ only ever evaluates selfish methods. Add this method as a custom renderer for the typeRelationalExpression
. During debugging you can then for instance click show() on an instance and enjoy the query graph it represents rendered in your standard browser.- Parameters:
renderSingleGroups
- whether to render group references with just one member- Returns:
- the String "Done."
-
-