Class QueryRecordFunctionWithComparison
- java.lang.Object
-
- com.apple.foundationdb.record.query.expressions.QueryRecordFunctionWithComparison
-
- All Implemented Interfaces:
PlanHashable
,ComponentWithComparison
,ComponentWithNoChildren
,QueryComponent
@API(MAINTAINED) public class QueryRecordFunctionWithComparison extends Object implements ComponentWithComparison
AComparisons.Comparison
whose value from the record, to be compared with the comparison's value, is the result of applying aRecordFunction
to the record.
-
-
Constructor Summary
Constructors Constructor Description QueryRecordFunctionWithComparison(RecordFunction<?> function, Comparisons.Comparison comparison)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
<M extends Message>
BooleanevalMessage(FDBRecordStoreBase<M> store, EvaluationContext context, FDBRecord<M> record, Message message)
Return whether or not the given record matches this component.<M extends Message>
CompletableFuture<Boolean>evalMessageAsync(FDBRecordStoreBase<M> store, EvaluationContext context, FDBRecord<M> record, Message message)
Asynchronous version ofevalMessage
.Comparisons.Comparison
getComparison()
RecordFunction<?>
getFunction()
String
getName()
int
hashCode()
boolean
isAsync()
Get whether this component is asynchronous.QueryPredicate
normalizeForPlanner(Source source, List<String> fieldNamePrefix)
Convert this query component into an equivalentQueryPredicate
by pushing all information about nested and repeated fields toElement
s inside ofElementPredicate
s.int
planHash()
Return a hash similar tohashCode
, 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)
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.apple.foundationdb.record.query.expressions.QueryComponent
eval, evalAsync, normalizeForPlanner
-
-
-
-
Constructor Detail
-
QueryRecordFunctionWithComparison
public QueryRecordFunctionWithComparison(@Nonnull RecordFunction<?> function, @Nonnull Comparisons.Comparison comparison)
-
-
Method Detail
-
getFunction
@Nonnull public RecordFunction<?> getFunction()
-
getComparison
@Nonnull public Comparisons.Comparison getComparison()
- Specified by:
getComparison
in interfaceComponentWithComparison
-
withOtherComparison
public QueryComponent withOtherComparison(Comparisons.Comparison comparison)
- Specified by:
withOtherComparison
in interfaceComponentWithComparison
-
getName
public String getName()
- Specified by:
getName
in interfaceComponentWithComparison
-
evalMessage
@Nullable public <M extends Message> Boolean evalMessage(@Nonnull FDBRecordStoreBase<M> store, @Nonnull EvaluationContext context, @Nullable FDBRecord<M> record, @Nullable Message message)
Description copied from interface:QueryComponent
Return whether or not the given record matches this component. The message might be the Protobuf form of a record or a piece of that record. If the key expression is meaningful against a subrecord, it should evaluate against the message. Otherwise, it should evaluate against the record and ignore what part of that record is being considered. There should not be any reason to call this method outside of the implementation of anotherevalMessage
. Under ordinary circumstances, ifrecord
isnull
, thenmessage
will benull
. Otherwise,message
will berecord.getRecord()
or some submessage of that, possiblynull
if the corresponding field is missing.- Specified by:
evalMessage
in interfaceQueryComponent
- Type Parameters:
M
- the type of record- Parameters:
store
- the record store from which the record camecontext
- context for bound expressionsrecord
- the recordmessage
- the Protobuf message to evaluate against- Returns:
- true/false/null, true if the given record should be included in results, false if it should not, and null if this component cannot determine whether it should be included or not
- See Also:
QueryComponent.eval(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreBase<M>, com.apple.foundationdb.record.EvaluationContext, com.apple.foundationdb.record.provider.foundationdb.FDBRecord<M>)
-
isAsync
public boolean isAsync()
Description copied from interface:QueryComponent
Get whether this component is asynchronous.- Specified by:
isAsync
in interfaceQueryComponent
- Returns:
true
if this component is better executed asynchronously
-
evalMessageAsync
@Nonnull public <M extends Message> CompletableFuture<Boolean> evalMessageAsync(@Nonnull FDBRecordStoreBase<M> store, @Nonnull EvaluationContext context, @Nullable FDBRecord<M> record, @Nullable Message message)
Description copied from interface:QueryComponent
Asynchronous version ofevalMessage
.- Specified by:
evalMessageAsync
in interfaceQueryComponent
- Type Parameters:
M
- the type of record- Parameters:
store
- the record store from which the record camecontext
- context for bound expressionsrecord
- the recordmessage
- the Protobuf message to evaluate against- Returns:
- a future that completes with whether the record should be included in the query result
- See Also:
QueryComponent.eval(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreBase<M>, com.apple.foundationdb.record.EvaluationContext, com.apple.foundationdb.record.provider.foundationdb.FDBRecord<M>)
-
validate
public void validate(@Nonnull Descriptors.Descriptor descriptor)
Description copied from interface:QueryComponent
Validate that the given descriptor is consistent with this component. e.g. it has all the fields defined that this component wants to inspect.- Specified by:
validate
in interfaceQueryComponent
- Parameters:
descriptor
- a record type descriptor, or a submessage descriptor
-
normalizeForPlanner
@Nonnull public QueryPredicate normalizeForPlanner(@Nonnull Source source, @Nonnull List<String> fieldNamePrefix)
Description copied from interface:QueryComponent
Convert this query component into an equivalentQueryPredicate
by pushing all information about nested and repeated fields toElement
s inside ofElementPredicate
s.This normalization process requires tracking some state: the name of a nested field is available only at the relevant
NestedField
, but that information is necessary to construct theElementPredicate
at the leaves of the sub-tree rooted at that nested field. This extra information is tracked in the givenfieldNamePrefix
.- Specified by:
normalizeForPlanner
in interfaceQueryComponent
- Parameters:
source
- the source representing the input stream of the key expressionfieldNamePrefix
- the (non-repeated) field names on the path from the most recent source to this part of the query component- Returns:
- an equivalent query predicate
-
planHash
public int planHash()
Description copied from interface:PlanHashable
Return a hash similar tohashCode
, but with the additional guarantee that is is stable across JVMs.- Specified by:
planHash
in interfacePlanHashable
- Returns:
- a stable hash code
-
-