Class ComparisonRange
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.temp.ComparisonRange
-
- All Implemented Interfaces:
PlanHashable
@API(EXPERIMENTAL) public class ComparisonRange extends Object implements PlanHashable
A set of compatible comparisons on a single field of aKeyExpression
representing a contiguous range of values for that field.A
ComparisonRange
is similar to aScanComparisons
but represents a contiguous range of values for a single field, rather than for an entireKeyExpression
. A comparison range is effectively a sum type, with the following options:- An empty set of comparisons, indicating that the entire universe of possible values is in the range.
-
An equality comparison on the field. There can only be a single such comparison. For example, single
comparison of the form
EQUALS "foo"
. -
A set of inequality comparisons that define a single contiguous range of values. For example, the combination
of the comparisons
> 8
and< 30
. The comparison range may include redundant comparisons by contract, but it may or may not simplify the range into a more compact form. For example, the comparison range can include the comparisons> 8
,< 30
, and< 20
, but it may optionally simplify this to> 8
and< 20
. Note that this behavior is not fully implemented right now; similarly, this implementation does not currently convert a range such as< 8
and> 30
to an empty range. However, this normalization logic will be added here in the future.
A
ComparisonRange
is an immutable object that provides a variety of methods for producing new range from the current one and someComparisons.Comparison
objects. For example, seetryToAdd(Comparisons.Comparison)
andfrom(Comparisons.Comparison)
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ComparisonRange.MergeResult
Class to represent the outcome of a merge operation.static class
ComparisonRange.Type
Comparison ranges can be divided into three types, with distinct planning behaviour: Empty ranges, to which any comparison can be added. Equality ranges, to which only the same (equality) comparison can be added. Inequality ranges, to which any other comparison can be added. This behavior is defined intryToAdd(Comparisons.Comparison)
.-
Nested classes/interfaces inherited from interface com.apple.foundationdb.record.PlanHashable
PlanHashable.PlanHashKind
-
-
Field Summary
Fields Modifier and Type Field Description static ComparisonRange
EMPTY
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
<M extends Message>
Booleaneval(FDBRecordStoreBase<M> store, EvaluationContext context, Object value)
static Optional<ComparisonRange>
from(Comparisons.Comparison comparison)
Comparisons.Comparison
getEqualityComparison()
List<Comparisons.Comparison>
getInequalityComparisons()
ComparisonRange.Type
getRangeType()
int
hashCode()
boolean
isEmpty()
boolean
isEquality()
boolean
isInequality()
ComparisonRange.MergeResult
merge(Comparisons.Comparison comparison)
ComparisonRange.MergeResult
merge(ComparisonRange comparisonRange)
int
planHash(PlanHashable.PlanHashKind hashKind)
Return a hash similar tohashCode
, but with the additional guarantee that is is stable across JVMs.String
toString()
Optional<ComparisonRange>
tryToAdd(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.PlanHashable
planHash
-
-
-
-
Field Detail
-
EMPTY
public static final ComparisonRange EMPTY
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
-
isEquality
public boolean isEquality()
-
isInequality
public boolean isInequality()
-
getRangeType
@Nonnull public ComparisonRange.Type getRangeType()
-
getEqualityComparison
@Nonnull public Comparisons.Comparison getEqualityComparison()
-
getInequalityComparisons
@Nullable public List<Comparisons.Comparison> getInequalityComparisons()
-
eval
public <M extends Message> Boolean eval(@Nonnull FDBRecordStoreBase<M> store, @Nonnull EvaluationContext context, @Nullable Object value)
-
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
-
tryToAdd
@Nonnull public Optional<ComparisonRange> tryToAdd(@Nonnull Comparisons.Comparison comparison)
-
merge
@Nonnull public ComparisonRange.MergeResult merge(@Nonnull Comparisons.Comparison comparison)
-
merge
@Nonnull public ComparisonRange.MergeResult merge(@Nonnull ComparisonRange comparisonRange)
-
from
@Nonnull public static Optional<ComparisonRange> from(@Nonnull Comparisons.Comparison comparison)
-
-