Class GroupExpressionRef<T extends RelationalExpression>
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.temp.GroupExpressionRef<T>
-
- Type Parameters:
T
- the type of planner expression that is contained in this reference
- All Implemented Interfaces:
Bindable
,ExpressionRef<T>
@API(EXPERIMENTAL) public class GroupExpressionRef<T extends RelationalExpression> extends Object implements ExpressionRef<T>
A Cascades-style group expression, representing the members of set ofRelationalExpression
s that belong to the same equivalence class.The memo data structure can compactly represent a large set of similar
RelationalExpression
s through careful memoization. The Cascades "group expression", represented by theGroupExpressionRef
, is the key to that memoization by sharing optimization work on a sub-expression with other parts of the expression that reference the same sub-expression.The reference abstraction is designed to make it difficult for authors of rules to mutate group expressions directly, which is undefined behavior. Note that a
GroupExpressionRef
cannot be "dereferenced" using theget()
method if it contains more than one member. Expressions with more than one member should not be used outside of the query planner, andget()
should not be used inside the query planner.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.apple.foundationdb.record.query.plan.temp.ExpressionRef
ExpressionRef.UngettableReferenceException
-
-
Constructor Summary
Constructors Modifier Constructor Description GroupExpressionRef()
protected
GroupExpressionRef(T expression)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.apple.foundationdb.record.query.plan.temp.ExpressionRef
bindTo
-
-
-
-
Method Detail
-
get
@Nonnull public T get()
Description copied from interface:ExpressionRef
Return the expression contained in this reference. If the reference does not support getting its expresssion (for example, because it holds more than one expression, or none at all), this should throw an exception.- Specified by:
get
in interfaceExpressionRef<T extends RelationalExpression>
- Returns:
- the expression contained in this reference
-
insert
public void insert(@Nonnull T newValue)
- Specified by:
insert
in interfaceExpressionRef<T extends RelationalExpression>
-
insertAll
public void insertAll(@Nonnull GroupExpressionRef<T> newValues)
-
containsAllInMemo
public boolean containsAllInMemo(@Nonnull ExpressionRef<? extends RelationalExpression> otherRef)
- Specified by:
containsAllInMemo
in interfaceExpressionRef<T extends RelationalExpression>
-
containsInMemo
public boolean containsInMemo(@Nonnull RelationalExpression expression)
-
clear
public void clear()
-
setExplored
public void setExplored()
-
isExplored
public boolean isExplored()
-
getMembers
@Nonnull public RelationalExpressionPointerSet<T> getMembers()
- Specified by:
getMembers
in interfaceExpressionRef<T extends RelationalExpression>
-
getNewRefWith
@Nonnull public ExpressionRef<T> getNewRefWith(@Nonnull T expression)
- Specified by:
getNewRefWith
in interfaceExpressionRef<T extends RelationalExpression>
-
bindWithin
@Nonnull public Stream<PlannerBindings> bindWithin(@Nonnull ExpressionMatcher<? extends Bindable> matcher)
Description copied from interface:ExpressionRef
Try to bind the given matcher to the members of this reference. If this reference has more than one member, it should try to match to any of them and produce a stream of bindings covering all possible combinations. If possible, this should be done in a lazy fashion using theStream
API, so as to minimize unnecessary work.- Specified by:
bindWithin
in interfaceExpressionRef<T extends RelationalExpression>
- Parameters:
matcher
- an expression matcher to match the member(s) of this reference with- Returns:
- a stream of bindings if the match succeeded or an empty stream if it failed
-
acceptPropertyVisitor
@Nullable public <U> U acceptPropertyVisitor(@Nonnull PlannerProperty<U> property)
- Specified by:
acceptPropertyVisitor
in interfaceExpressionRef<T extends RelationalExpression>
-
map
@Nonnull public <U extends RelationalExpression> ExpressionRef<U> map(@Nonnull Function<T,U> func)
- Specified by:
map
in interfaceExpressionRef<T extends RelationalExpression>
-
flatMapNullable
@Nullable public <U extends RelationalExpression> ExpressionRef<U> flatMapNullable(@Nonnull Function<T,ExpressionRef<U>> nullableFunc)
- Specified by:
flatMapNullable
in interfaceExpressionRef<T extends RelationalExpression>
-
of
public static <T extends RelationalExpression> GroupExpressionRef<T> of(@Nonnull T expression)
-
of
public static <T extends RelationalExpression> GroupExpressionRef<T> of(@Nonnull T... expressions)
-
from
public static <T extends RelationalExpression> GroupExpressionRef<T> from(@Nonnull Collection<T> expressions)
-
-