Class EmptyComparison
- java.lang.Object
-
- com.apple.foundationdb.record.query.expressions.BaseField
-
- com.apple.foundationdb.record.query.expressions.EmptyComparison
-
- All Implemented Interfaces:
PlanHashable
,ComponentWithNoChildren
,QueryComponent
,QueryHashable
@API(MAINTAINED) public class EmptyComparison extends BaseField implements ComponentWithNoChildren
A comparison to determine whether a repeated field is empty (has no occurrences).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.apple.foundationdb.record.PlanHashable
PlanHashable.PlanHashKind
-
Nested classes/interfaces inherited from interface com.apple.foundationdb.record.QueryHashable
QueryHashable.QueryHashKind
-
-
Constructor Summary
Constructors Constructor Description EmptyComparison(String fieldName, boolean isEmpty)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
basePlanHash(PlanHashable.PlanHashKind hashKind, ObjectPlanHash baseHash, Object... hashables)
Base implementation ofPlanHashable.planHash(com.apple.foundationdb.record.PlanHashable.PlanHashKind)
.protected int
baseQueryHash(QueryHashable.QueryHashKind hashKind, ObjectPlanHash baseHash, Object... hashables)
Base implementation ofQueryHashable.queryHash(com.apple.foundationdb.record.QueryHashable.QueryHashKind)
.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.GraphExpansion
expand(CorrelationIdentifier baseAlias, List<String> fieldNamePrefix)
Expand this query component into a data flow graph.Field.OneOfThemEmptyMode
getEmptyMode()
protected List<Object>
getValues(MessageOrBuilder message)
int
hashCode()
boolean
isEmpty()
int
planHash(PlanHashable.PlanHashKind hashKind)
Return a hash similar tohashCode
, but with the additional guarantee that is is stable across JVMs.int
queryHash(QueryHashable.QueryHashKind hashKind)
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.protected Descriptors.FieldDescriptor
validateRepeatedField(Descriptors.Descriptor descriptor)
-
Methods inherited from class com.apple.foundationdb.record.query.expressions.BaseField
findFieldDescriptor, getFieldName, getFieldValue, getName, requireMessageField, requirePrimitiveField, requireScalarField, validateFieldExistence
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.apple.foundationdb.record.PlanHashable
planHash
-
Methods inherited from interface com.apple.foundationdb.record.query.expressions.QueryComponent
eval, evalAsync, evalMessageAsync, expand, isAsync
-
-
-
-
Method Detail
-
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>)
-
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
-
isEmpty
public boolean isEmpty()
-
expand
public GraphExpansion expand(@Nonnull CorrelationIdentifier baseAlias, @Nonnull List<String> fieldNamePrefix)
Description copied from interface:QueryComponent
Expand this query component into a data flow graph. The returned graph represents an adequate representation of the component as composition of relational expressions and operators.- Specified by:
expand
in interfaceQueryComponent
- Parameters:
baseAlias
- a an alias that refers to the data flow equivalent of an input to this componentfieldNamePrefix
- a list of field names that accumulate a field nesting chain for non-repeated fields- Returns:
- a new
GraphExpansion
representing the query graph equivalent of this query component - See Also:
TODO make this method private in Java 11
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
planHash
public int planHash(@Nonnull PlanHashable.PlanHashKind hashKind)
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
- Parameters:
hashKind
- the "kind" of hash to calculate. Each kind of hash has a particular logic with regards to included and excluded items.- Returns:
- a stable hash code
-
queryHash
public int queryHash(@Nonnull QueryHashable.QueryHashKind hashKind)
Description copied from interface:QueryHashable
Return a hash similar tohashCode
, but with the additional guarantee that is is stable across JVMs.- Specified by:
queryHash
in interfaceQueryHashable
- Parameters:
hashKind
- the "kind" of hash to calculate. Each kind of hash has a particular logic with regards to included and excluded items.- Returns:
- a stable hash code
-
getEmptyMode
@Nonnull public Field.OneOfThemEmptyMode getEmptyMode()
-
getValues
@Nullable protected List<Object> getValues(@Nonnull MessageOrBuilder message)
-
validateRepeatedField
@Nonnull protected Descriptors.FieldDescriptor validateRepeatedField(@Nonnull Descriptors.Descriptor descriptor)
-
basePlanHash
protected int basePlanHash(@Nonnull PlanHashable.PlanHashKind hashKind, ObjectPlanHash baseHash, Object... hashables)
Base implementation ofPlanHashable.planHash(com.apple.foundationdb.record.PlanHashable.PlanHashKind)
. This implementation makes each concrete subclass implement its own version ofPlanHashable.planHash(com.apple.foundationdb.record.PlanHashable.PlanHashKind)
so that they are guided to add their own class modifier (SeeObjectPlanHash
). This implementation is meant to give subclasses common functionality for their own implementation.- Overrides:
basePlanHash
in classBaseField
- Parameters:
hashKind
- the plan hash kind to usebaseHash
- the subclass' base hash (concrete identifier)hashables
- the rest of the subclass' hashable parameters (if any)- Returns:
- the plan hash value calculated
-
baseQueryHash
protected int baseQueryHash(@Nonnull QueryHashable.QueryHashKind hashKind, ObjectPlanHash baseHash, Object... hashables)
Base implementation ofQueryHashable.queryHash(com.apple.foundationdb.record.QueryHashable.QueryHashKind)
. This implementation makes each concrete subclass implement its own version ofQueryHashable.queryHash(com.apple.foundationdb.record.QueryHashable.QueryHashKind)
so that they are guided to add their own class modifier (SeeObjectPlanHash
). This implementation is meant to give subclasses common functionality for their own implementation.- Overrides:
baseQueryHash
in classBaseField
- Parameters:
hashKind
- the query hash kind to usebaseHash
- the subclass' base hash (concrete identifier)hashables
- the rest of the subclass' hashable parameters (if any)- Returns:
- the query hash value calculated
-
-