@API(value=EXPERIMENTAL) public class QueryKeyExpressionWithComparison extends Object implements ComponentWithComparison
Constructor and Description |
---|
QueryKeyExpressionWithComparison(QueryableKeyExpression keyExpression,
Comparisons.Comparison comparison) |
Modifier and Type | Method and Description |
---|---|
ExpressionRef<QueryComponent> |
asNestedWith(NestedContext nestedContext,
ExpressionRef<QueryComponent> thisRef)
Produce an exactly equivalent version of the
PlannerExpression tree rooted at this QueryComponent
as if all operations were nested inside the given NestedContext . |
ExpressionRef<QueryComponent> |
asUnnestedWith(NestedContext nestedContext,
ExpressionRef<QueryComponent> thisRef)
Produce an exactly equivalent version of the
PlannerExpression tree rooted at this QueryComponent
with all operations placed inside the field given by the NestedContext . |
boolean |
equals(Object o) |
boolean |
equalsWithoutChildren(PlannerExpression otherExpression) |
<M extends Message> |
evalMessage(FDBRecordStoreBase<M> store,
EvaluationContext context,
FDBRecord<M> record,
Message message)
Return whether or not the given record matches this component.
|
Comparisons.Comparison |
getComparison() |
QueryableKeyExpression |
getKeyExpression() |
String |
getName() |
Iterator<? extends ExpressionRef<? extends PlannerExpression>> |
getPlannerExpressionChildren()
Return an iterator of references to the children of this planner expression.
|
int |
hashCode() |
int |
planHash()
Return a hash similar to
hashCode , but with the additional guarantee that is is stable across JVMs. |
String |
toString() |
void |
validate(Descriptors.Descriptor descriptor)
Validate that the given descriptor is consistent with this component.
|
QueryComponent |
withOtherComparison(Comparisons.Comparison comparison) |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
eval, evalAsync, evalMessageAsync, isAsync
combineHashes, iterablePlanHash, objectPlanHash, objectsPlanHash, planHash, planHash, planHashUnordered, stringHashUnordered
acceptPropertyVisitor, bindTo
public QueryKeyExpressionWithComparison(@Nonnull QueryableKeyExpression keyExpression, @Nonnull Comparisons.Comparison comparison)
@Nonnull public QueryableKeyExpression getKeyExpression()
@Nullable public <M extends Message> Boolean evalMessage(@Nonnull FDBRecordStoreBase<M> store, @Nonnull EvaluationContext context, @Nullable FDBRecord<M> record, @Nullable Message message)
QueryComponent
evalMessage
.
Under ordinary circumstances, if record
is null
, then message
will be null
.
Otherwise, message
will be record.getRecord()
or some submessage of that, possibly null
if
the corresponding field is missing.evalMessage
in interface QueryComponent
M
- the type of recordstore
- the record store from which the record camecontext
- context for bound expressionsrecord
- the recordmessage
- the Protobuf message to evaluate againstQueryComponent.eval(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreBase<M>, com.apple.foundationdb.record.EvaluationContext, com.apple.foundationdb.record.provider.foundationdb.FDBRecord<M>)
public void validate(@Nonnull Descriptors.Descriptor descriptor)
QueryComponent
validate
in interface QueryComponent
descriptor
- a record type descriptor, or a submessage descriptor@Nonnull public Comparisons.Comparison getComparison()
getComparison
in interface ComponentWithComparison
@Nonnull public Iterator<? extends ExpressionRef<? extends PlannerExpression>> getPlannerExpressionChildren()
PlannerExpression
Collections.emptyIterator()
is returned. The returned iterator should
be treated as an immutable object and may throw an exception if Iterator.remove()
is called.
The iterator must return its elements in a consistent order.getPlannerExpressionChildren
in interface PlannerExpression
@Nullable public ExpressionRef<QueryComponent> asNestedWith(@Nonnull NestedContext nestedContext, @Nonnull ExpressionRef<QueryComponent> thisRef)
QueryComponent
PlannerExpression
tree rooted at this QueryComponent
as if all operations were nested inside the given NestedContext
. That is, transform all predicates, index
scans, and other operations to the form that they would have if they were nested within the field given by the
parent field of the given nested context. If it is not possible to produce such an expression, return null
.
With QueryComponent.asUnnestedWith(NestedContext, ExpressionRef)
, this method should obey the contract that, for any
expression
and nestedContext
,
expression.asNestedWith(nestedContext, ref).asUnnestedWith(nestedContext, ref)
is either equal to
expression
(according to the equals()
comparison) or null
.
For example, if this component is the predicate field("a").matches(field("b).equals(3))
and the
nestedContext
is built around field("a")
, then this method would return a reference containing
the predicate field("b").equals(3)
.
The thisRef
parameter has two uses. For some implementations of asNestedWith()
, the expression
does not need to be changed, and so it is more efficient to return the containing reference than to build a
new one. Additionally, it is used to generate a reference of the appropriate type using the
ExpressionRef.getNewRefWith(PlannerExpression)
.
asNestedWith
in interface QueryComponent
nestedContext
- a context describing the field to use for nestingthisRef
- the reference that contains this query component@Nullable public ExpressionRef<QueryComponent> asUnnestedWith(@Nonnull NestedContext nestedContext, @Nonnull ExpressionRef<QueryComponent> thisRef)
QueryComponent
PlannerExpression
tree rooted at this QueryComponent
with all operations placed inside the field given by the NestedContext
. That is, put all predicates,
index scans, and other operations within the given nested field. If it is not possible to produce such an
expression, return null
.
With QueryComponent.asNestedWith(NestedContext, ExpressionRef)
, this method should obey the contract that, for any
expression
and nestedContext
,
expression.asNestedWith(nestedContext, ref).asUnnestedWith(nestedContext, ref)
is either equal to
expression
(according to the equals()
comparison) or null
.
For example, if this component is the predicate field("b).equals(3)
and the nestedContext
is
built around field("a")
, then this method would return a reference containing
the predicate field("a").matches(field("b").equals(3))
.
The thisRef
parameter has two uses. For some implementations of asUnnestedWith()
, the expression
does not need to be changed, and so it is more efficient to return the containing reference than to build a
new one. Additionally, it is used to generate a reference of the appropriate type using the
ExpressionRef.getNewRefWith(PlannerExpression)
.
asUnnestedWith
in interface QueryComponent
nestedContext
- a context describing the field to use for unnestingthisRef
- the reference that contains this query component@API(value=EXPERIMENTAL) public boolean equalsWithoutChildren(@Nonnull PlannerExpression otherExpression)
equalsWithoutChildren
in interface PlannerExpression
public int planHash()
PlanHashable
hashCode
, but with the additional guarantee that is is stable across JVMs.planHash
in interface PlanHashable
public QueryComponent withOtherComparison(Comparisons.Comparison comparison)
withOtherComparison
in interface ComponentWithComparison
public String getName()
getName
in interface ComponentWithComparison