Interface ExpressionRef<T extends RelationalExpression>
-
- Type Parameters:
T
- the type of planner expression that is contained in this reference
- All Superinterfaces:
Bindable
,Correlated<ExpressionRef<T>>
- All Known Implementing Classes:
GroupExpressionRef
@API(EXPERIMENTAL) public interface ExpressionRef<T extends RelationalExpression> extends Bindable, Correlated<ExpressionRef<T>>
This interface is used mostly as an (admittedly surmountable) barrier to rules mutating bound references directly, which is undefined behavior.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ExpressionRef.UngettableReferenceException
An exception thrown whenget()
is called on a reference that does not support it, such as a group reference.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <U> U
acceptPropertyVisitor(PlannerProperty<U> property)
boolean
addAllPartialMatchesForCandidate(MatchCandidate candidate, Iterable<PartialMatch> partialMatches)
Add thePartialMatch
es passed in to this reference for theMatchCandidate
passed in.default Stream<PlannerBindings>
bindTo(ExpressionMatcher<? extends Bindable> matcher)
Try to bind the given matcher to this reference.Stream<PlannerBindings>
bindWithin(ExpressionMatcher<? extends Bindable> matcher)
Try to bind the given matcher to the members of this reference.boolean
containsAllInMemo(ExpressionRef<? extends RelationalExpression> otherRef, AliasMap equivalenceMap)
<U extends RelationalExpression>
ExpressionRef<U>flatMapNullable(Function<T,ExpressionRef<U>> nullableFunc)
T
get()
Return the expression contained in this reference.Set<MatchCandidate>
getMatchCandidates()
Return all match candidates that partially match this reference.RelationalExpressionPointerSet<T>
getMembers()
ExpressionRef<T>
getNewRefWith(T expression)
Set<PartialMatch>
getPartialMatchesForCandidate(MatchCandidate candidate)
Return all partial matches for theMatchCandidate
passed in.boolean
insert(T newValue)
Insert a new expression into this reference.<U extends RelationalExpression>
ExpressionRef<U>map(Function<T,U> func)
-
Methods inherited from interface com.apple.foundationdb.record.query.plan.temp.Correlated
getCorrelatedTo, rebase, semanticEquals, semanticHashCode
-
-
-
-
Method Detail
-
insert
boolean insert(@Nonnull T newValue)
Insert a new expression into this reference.- Parameters:
newValue
- the value to be inserted- Returns:
true
if the value was not already part of the reference and was inserted,false
if the given value was already contained in the reference and was therefore not inserted.
-
get
@Nonnull T get()
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.- Returns:
- the expression contained in this reference
- Throws:
ExpressionRef.UngettableReferenceException
- if the reference does not support retrieving its expression
-
acceptPropertyVisitor
@Nullable <U> U acceptPropertyVisitor(@Nonnull PlannerProperty<U> property)
-
bindTo
@Nonnull default Stream<PlannerBindings> bindTo(@Nonnull ExpressionMatcher<? extends Bindable> matcher)
Try to bind the given matcher to this reference. It should not try to match to the members of the reference; if the given matcher needs to match to aRelationalExpression
rather than anExpressionRef
, it will callbindWithin(ExpressionMatcher)
instead.Binding to references can be a bit subtle: some matchers (such as
ReferenceMatcher
) can bind to references directly while others (such asTypeMatcher
) can't, since they need access to the underlying operator which might not even be well defined. This method implements binding to the reference, rather than to its member(s).
-
bindWithin
@Nonnull Stream<PlannerBindings> bindWithin(@Nonnull ExpressionMatcher<? extends Bindable> matcher)
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.- 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
-
map
@Nonnull <U extends RelationalExpression> ExpressionRef<U> map(@Nonnull Function<T,U> func)
-
flatMapNullable
@Nullable <U extends RelationalExpression> ExpressionRef<U> flatMapNullable(@Nonnull Function<T,ExpressionRef<U>> nullableFunc)
-
getNewRefWith
@Nonnull ExpressionRef<T> getNewRefWith(@Nonnull T expression)
-
containsAllInMemo
boolean containsAllInMemo(@Nonnull ExpressionRef<? extends RelationalExpression> otherRef, @Nonnull AliasMap equivalenceMap)
-
getMembers
RelationalExpressionPointerSet<T> getMembers()
-
getMatchCandidates
@Nonnull Set<MatchCandidate> getMatchCandidates()
Return all match candidates that partially match this reference. This set must be a subset of allMatchCandidate
s in thePlanContext
during planning. Note that it is possible that a particular match candidate matches this reference more than once.- Returns:
- a set of match candidates that partially match this reference.
-
getPartialMatchesForCandidate
@Nonnull Set<PartialMatch> getPartialMatchesForCandidate(MatchCandidate candidate)
Return all partial matches for theMatchCandidate
passed in.- Parameters:
candidate
- match candidate- Returns:
- a set of partial matches for
candidate
-
addAllPartialMatchesForCandidate
boolean addAllPartialMatchesForCandidate(MatchCandidate candidate, Iterable<PartialMatch> partialMatches)
Add thePartialMatch
es passed in to this reference for theMatchCandidate
passed in.- Parameters:
candidate
- match candidate this partial match relates topartialMatches
- a set of partial matches.- Returns:
true
if this call added new partial matches,false
if all partial matches were already contained in this reference
-
-