Class ComparisonRange
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.temp.ComparisonRange
-
@API(EXPERIMENTAL) public class ComparisonRange extends Object
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.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)
.
-
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)
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()
String
toString()
Optional<ComparisonRange>
tryToAdd(Comparisons.Comparison comparison)
-
-
-
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()
-
tryToAdd
@Nonnull public Optional<ComparisonRange> tryToAdd(@Nonnull Comparisons.Comparison comparison)
-
from
@Nonnull public static Optional<ComparisonRange> from(@Nonnull Comparisons.Comparison comparison)
-
-