fdb-record-layer
fdb-record-layer copied to clipboard
change modeling of `OrderingPart` to use a sort order instead of a boolean for reversedness
This is related to #1318. It would be useful to state that certain ordering parts are fixed, i.e. bound to one value vie an e.g. equality predicate. In those cases forward and backward become meaningless, they would both fit.
This issue addresses replacing the isReverse
with a new enum SortOrder
which can be ASCENDING
, DESCENDING
, and FIXED
.
There are some places in the codebase where we reason about Ordering
and in particular OrderingPart
s where we rely on the equality of OrderingPart
s. An ordering part (q.a, ASC)
is equal to (q.a, ASC)
only, in particular it is not equal to (q.a, DESC)
, (q.a, FIXED)
.
Unfortunately, a RequestedOrdering
which is used to enumerate satisfying orderings does not want equality but just compatibility, i.e. a requested ordering of (q.a, ASC)
or (q.a, DESC)
are both compatible with (q.a, FIXED)
even though they are not equal. All of this is part of Ordering.enumerateSatisfyingOrderings()
and Ordering.enumerateSatisfyingOrderingComparisonKeyValues()
.
Similarly, merging two Ordering
s has a similar problem. An ordering (q.a, ASC)
and an ordering (q.a, FIXED)
should be merged to (q.a, ASC)
. The code that needs to be adapted is in Ordering.mergePartialOrderOfOrderings()
which (again) only considers equality instead of compatibility.