@API(value=STABLE) public interface QueryComponent extends PlanHashable, PlannerExpression
validate(Descriptors.Descriptor)
must be called before calling eval(FDBRecordStoreBase, EvaluationContext, FDBRecord)
, or bad
things may happen.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 . |
default <M extends Message> |
eval(FDBRecordStoreBase<M> store,
EvaluationContext context,
FDBRecord<M> record)
Return whether or not the given record matches this component.
|
default <M extends Message> |
evalAsync(FDBRecordStoreBase<M> store,
EvaluationContext context,
FDBRecord<M> record)
Asynchronous version of
eval . |
<M extends Message> |
evalMessage(FDBRecordStoreBase<M> store,
EvaluationContext context,
FDBRecord<M> record,
Message message)
Return whether or not the given record matches this component.
|
default <M extends Message> |
evalMessageAsync(FDBRecordStoreBase<M> store,
EvaluationContext context,
FDBRecord<M> record,
Message message)
Asynchronous version of
evalMessage . |
default boolean |
isAsync()
Get whether this component is asynchronous.
|
void |
validate(Descriptors.Descriptor descriptor)
Validate that the given descriptor is consistent with this component.
|
combineHashes, iterablePlanHash, objectPlanHash, objectsPlanHash, planHash, planHash, planHash, planHashUnordered, stringHashUnordered
acceptPropertyVisitor, bindTo, equalsWithoutChildren, getPlannerExpressionChildren
@Nullable default <M extends Message> Boolean eval(@Nonnull FDBRecordStoreBase<M> store, @Nonnull EvaluationContext context, @Nullable FDBRecord<M> record)
evalMessage(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreBase<M>, com.apple.foundationdb.record.EvaluationContext, com.apple.foundationdb.record.provider.foundationdb.FDBRecord<M>, com.google.protobuf.Message)
instead of this one, even if they do not deal with
Protobuf messages, so that they interact properly with expressions that do.M
- the type of recordsstore
- the record store from which the record camecontext
- context against which evaluation takes placerecord
- a record of the appropriate record type for this component@Nullable <M extends Message> Boolean evalMessage(@Nonnull FDBRecordStoreBase<M> store, @Nonnull EvaluationContext context, @Nullable FDBRecord<M> record, @Nullable Message message)
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.M
- the type of recordstore
- the record store from which the record camecontext
- context for bound expressionsrecord
- the recordmessage
- the Protobuf message to evaluate againsteval(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreBase<M>, com.apple.foundationdb.record.EvaluationContext, com.apple.foundationdb.record.provider.foundationdb.FDBRecord<M>)
@Nonnull default <M extends Message> CompletableFuture<Boolean> evalAsync(@Nonnull FDBRecordStoreBase<M> store, @Nonnull EvaluationContext context, @Nullable FDBRecord<M> record)
eval
.M
- the type of recordsstore
- the record store from which the record camecontext
- context against which evaluation takes placerecord
- a record of the appropriate record type for this componenteval(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreBase<M>, com.apple.foundationdb.record.EvaluationContext, com.apple.foundationdb.record.provider.foundationdb.FDBRecord<M>)
@Nonnull default <M extends Message> CompletableFuture<Boolean> evalMessageAsync(@Nonnull FDBRecordStoreBase<M> store, @Nonnull EvaluationContext context, @Nullable FDBRecord<M> record, @Nullable Message message)
evalMessage
.M
- the type of recordstore
- the record store from which the record camecontext
- context for bound expressionsrecord
- the recordmessage
- the Protobuf message to evaluate againsteval(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreBase<M>, com.apple.foundationdb.record.EvaluationContext, com.apple.foundationdb.record.provider.foundationdb.FDBRecord<M>)
default boolean isAsync()
true
if this component is better executed asynchronouslyvoid validate(@Nonnull Descriptors.Descriptor descriptor)
descriptor
- a record type descriptor, or a submessage descriptorQuery.InvalidExpressionException
- if the descriptor is not consistent with this component@Nullable @API(value=EXPERIMENTAL) ExpressionRef<QueryComponent> asNestedWith(@Nonnull NestedContext nestedContext, @Nonnull ExpressionRef<QueryComponent> thisRef)
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 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)
.
nestedContext
- a context describing the field to use for nestingthisRef
- the reference that contains this query component@Nullable @API(value=EXPERIMENTAL) ExpressionRef<QueryComponent> asUnnestedWith(@Nonnull NestedContext nestedContext, @Nonnull ExpressionRef<QueryComponent> thisRef)
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 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)
.
nestedContext
- a context describing the field to use for unnestingthisRef
- the reference that contains this query component