Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary: Work In Progress / Request For Comments
Introduces a new struct SliceBound that provides a general way of specifying upper
and lower bounds for ranges of keys. Eventually this could be used for many APIs, including
DeleteRange, CompactRange, Iterator bounds, Iterator Seek locations, and more. This is intended
to solve many related problems:
and can easily cause bugs. It is more user-friendly if exclusivity follows from the specification of
the bound itself, not what this particular API prefers.
comparator and want to seek to the start of prefix "foo", the best I can do is seek to "foo"
followed by a more 0xff chars than I hope to actually use, or seek to "fop" (nullifying opportunity
for prefix seek optimization) and skip over any "fop" entry. See also issue No way to specify infinite upper bound to query properties/approximate size #11027
really documented and could easily be a source of bugs. Like exclusivity, it's much more
user-friendly if the bound itself specifies whether it includes a user timestamp, rather than
committing each API as interpreting one way or another. (By the way, the existing interpretation
of bounds seems counter to the idea that the layout of user timestamps in keys is hidden
from the user, except in the implementation of Comparator.)
customization of the feature (at least in theory). SliceBound should offer a way to name
a position before all or after all versions of a key, without assuming a meaning for certain
timestamp values.
it typically inclusive, but can be exclusive if the last key is only referring to the upper bound of
a range tombstone. If we translate these ranges to SliceBound, they fit into a generic framework
for key ranges, including checking overlap, etc.
auto_prefix_modeis a rather awkward and somewhat broken way to prefix filtering, oftenrequiring copying & modifying keys for bounds.
prefix_same_as_startis arguably bug-pronebecause the meaning of a read operation is tied to the current prefix extractor. SliceBound
should be able to solve these issues by making it simple to scan a specific prefix, regardless
of current prefix extractor setting.
There is likely to be a performance cost associated with comparing against these generalized
bounds, though most of it will likely be optimized with function inlining. However, the savings
in avoiding copying and modifying keys to construct bounds might sufficiently offset these
overheads.
There is an existing related idea called Endpoint in transaction.h, but it is not nearly as general
or as well specified. (Lacking unit tests; not clear what reverse comparator semantics are; doesn't
add clarity to inclusive vs. exclusive bounds; unclear timestamp semantics)
See comparator.h changes for details.
Test Plan: TODO
The APIs mentioned in #11027 would likely be the first upgraded to support SliceBound.