combineRangeBounds function
If a and b are a lower-bound and an upper-bound range filter on the same
field, combines them into a single BoundedRangeFilter for one bounded index
scan. Returns null when they are not a complementary bound pair.
Implementation
ComparableFilter? combineRangeBounds(ComparableFilter a, ComparableFilter b) {
if (a is! SortingAwareFilter || b is! SortingAwareFilter) return null;
if (a.field != b.field) return null;
SortingAwareFilter? lower, upper;
for (var f in [a, b]) {
if (f.boundType == RangeBoundType.lower) {
lower = f;
} else if (f.boundType == RangeBoundType.upper) {
upper = f;
}
}
if (lower != null && upper != null) {
return BoundedRangeFilter(a.field, lower, upper);
}
return null;
}