Class ComparisonRange

  • All Implemented Interfaces:
    PlanHashable

    @API(EXPERIMENTAL)
    public class ComparisonRange
    extends Object
    implements PlanHashable
    A set of compatible comparisons on a single field of a KeyExpression representing a contiguous range of values for that field.

    A ComparisonRange is similar to a ScanComparisons but represents a contiguous range of values for a single field, rather than for an entire KeyExpression. 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 some Comparisons.Comparison objects. For example, see tryToAdd(Comparisons.Comparison) and from(Comparisons.Comparison).