@API(value=EXPERIMENTAL) public class KeyExpressionComparisons extends Object
KeyExpression
with a ComparisonRange
on some of its sub-expressions.
A KeyExpressionComparisons
is an analogue of a ScanComparisons
that maintains information about which
parts of a KeyExpression
correspond to each comparison. It maintains a (private) tree that mirrors the
underlying key expression and maps each part of the key expression to a ComparisonRange
that represents
a contiguous range of values for that part of the key expression. The matchWith(ComponentWithComparison)
method can then take a ComponentWithComparison
and try to add it to the existing comparisons.
The KeyExpressionComparisons
encapsulates the core logic of marking parts of a complex key expression as
satisfied by various types of Comparisons.Comparison
s and attempting to match more comparisons to the
remaining parts of the expression. It is also designed to support queries about compatible sort orders, given the
set of existing comparisons.
While this sounds a lot like a whole query planner, the scope of a KeyExpressionComparisons
is intentionally
very limited. In particular, it supports matching with a ComponentWithComparison
rather than a more
general QueryComponent
. As a result, the logic for handling
Boolean operations, nested messages, and other complexities does not belong in KeyExpressionComparisons
.
This is especially important becuase it relies on instanceof
checking to properly match query components with
compatible key expressions; this code is vastly simpler because it only needs to consider
ComponentWithComparison
s.
Constructor and Description |
---|
KeyExpressionComparisons(KeyExpression keyExpression) |
Modifier and Type | Method and Description |
---|---|
KeyExpressionComparisons |
asNestedWith(NestedContext nestedContext) |
KeyExpressionComparisons |
asUnnestedWith(NestedContext nestedContext) |
boolean |
equals(Object o) |
int |
getUnmatchedFieldCount() |
int |
hashCode() |
boolean |
hasUnmatchedFieldCreatingDuplicates() |
Optional<KeyExpressionComparisons> |
matchWith(ComponentWithComparison component) |
boolean |
supportsSortOrder(KeyExpressionComparisons sortExpression) |
ScanComparisons |
toScanComparisons() |
public KeyExpressionComparisons(@Nonnull KeyExpression keyExpression)
@Nonnull public Optional<KeyExpressionComparisons> matchWith(@Nonnull ComponentWithComparison component)
public boolean supportsSortOrder(@Nonnull KeyExpressionComparisons sortExpression)
@Nonnull public ScanComparisons toScanComparisons()
@Nullable public KeyExpressionComparisons asNestedWith(@Nonnull NestedContext nestedContext)
@Nonnull public KeyExpressionComparisons asUnnestedWith(@Nonnull NestedContext nestedContext)
public int getUnmatchedFieldCount()
public boolean hasUnmatchedFieldCreatingDuplicates()