-
#include "tensorstore/kvstore/key_range.h" - class tensorstore::KeyRange;
Specifies a range of keys according to their unsigned lexicographical order.
The range includes all keys
xsatisfyinginclusive_min <= x < exclusive_max.As a special case, if
exclusive_max.empty(), the range has no upper bound, i.e. it contains all keysxsatisfyinginclusive_min <= x.Due to the special interpretation of
exclusive_max.empty(), it is not possible to represent the empty range that starts with (but does not include) the empty string. An empty range starting at (but not including) any other stringxcan be represented withinclusive_min = inclusive_max = x, but empty ranges are not normally needed.Constructors¶
- KeyRange();
Constructs the range containing all keys.
-
explicit KeyRange(std::string inclusive_min,
std::string exclusive_max); Constructs the specified range.
Methods¶
- static KeyRange EmptyRange();
Returns a range that contains no keys.
- static KeyRange Prefix(std::string prefix);
Returns the range that contains all keys that start with
prefix.
- static KeyRange AddPrefix(std::string_view prefix, KeyRange range);
Adds a prefix to both
inclusive_minandexclusive_max.
- static KeyRange RemovePrefix(std::string_view prefix, KeyRange range);
Returns the range corresponding to the set of keys
kfor whichprefix + kis a member ofrange.
- static KeyRange RemovePrefixLength(size_t n, const KeyRange& range);
Removes
ncharacters from the prefix of range.
- static std::string Successor(std::string_view key);
Returns the key that occurs immediately after
key.
- static std::string PrefixExclusiveMax(std::string_view prefix);
Returns the
exclusive_maxvalue representing the upper bound for keys that start withprefix.
-
static std::weak_ordering
CompareKeyAndExclusiveMax(std::string_view key,
std::string_view bound); -
static std::weak_ordering
CompareExclusiveMaxAndKey(std::string_view bound,
std::string_view key); Returns the three-way comparison result between a key and an exclusive max bound.
-
static std::weak_ordering
CompareExclusiveMax(std::string_view a, std::string_view b); Returns the three-way comparison result between two
exclusive_maxvalues.
- bool empty() const;
Returns
trueif the range contains no keys.
- bool full() const;
Returns
trueif the range contains all keys.
- bool is_singleton() const;
Returns
trueif the key range is a singleton.
- bool is_non_empty_prefix() const;
Returns
trueif the key range is a non-empty prefix.
Friend functions¶
- friend bool operator==(const KeyRange& a, const KeyRange& b);
- friend bool operator!=(const KeyRange& a, const KeyRange& b);
Compares two ranges for equality.
-
friend std::ostream&
operator<<(std::ostream& os, const KeyRange& range); Prints a debugging string representation to an
std::ostream.
Data members¶
- std::string inclusive_min;
Inclusive lower bound of the range.
- std::string exclusive_max;
Exclusive upper bound of the range, or an empty string to indicate no upper bound.
Related Functions¶
-
bool tensorstore::Contains(const KeyRange& haystack,
std::string_view needle);
-
bool tensorstore::ContainsPrefix(const KeyRange& haystack,
std::string_view prefix);
- bool tensorstore::Intersects(const KeyRange& a, const KeyRange& b);
-
bool tensorstore::IntersectsPrefix(const KeyRange& a,
std::string_view prefix); Returns
Intersects(a, KeyRange::Prefix(prefix)).
- std::string_view tensorstore::LongestPrefix(const KeyRange& range);
Returns the longest string
prefixthat satisfiesContains(range, KeyRange::Prefix(prefix)).