#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 x satisfying inclusive_min <= x < exclusive_max.

As a special case, if exclusive_max.empty(), the range has no upper bound, i.e. it contains all keys x satisfying inclusive_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 string x can be represented with inclusive_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 prefixKeyRange range);

Adds a prefix to both inclusive_min and exclusive_max.

static KeyRange RemovePrefix(std::string_view prefixKeyRange range);

Returns the range corresponding to the set of keys k for which prefix + k is a member of range.

static KeyRange RemovePrefixLength(size_t nconst KeyRangerange);

Removes n characters from the prefix of range.

static std::string Successor(std::string_view key);

Returns the key that occurs immediately after key.

static KeyRange Singleton(std::string key);

Returns a range containing the single specified key.

static std::string PrefixExclusiveMax(std::string_view prefix);

Returns the exclusive_max value representing the upper bound for keys that start with prefix.

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 astd::string_view b);

Returns the three-way comparison result between two exclusive_max values.

bool empty() const;

Returns true if the range contains no keys.

bool full() const;

Returns true if the range contains all keys.

bool is_singleton() const;

Returns true if the key range is a singleton.

bool is_non_empty_prefix() const;

Returns true if the key range is a non-empty prefix.

Friend functions

friend bool operator==(const KeyRangeaconst KeyRangeb);
friend bool operator!=(const KeyRangeaconst KeyRangeb);

Compares two ranges for equality.

friend std::ostream&
operator<<(std::ostreamosconst KeyRangerange);

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.

bool tensorstore::Contains(const KeyRangehaystack,
                           
std::string_view needle);

Returns true if haystack contains the key needle.

bool tensorstore::Contains(const KeyRangehaystack,
                           
const KeyRangeneedle);

Returns true if haystack fully contains the range needle.

bool tensorstore::ContainsPrefix(const KeyRangehaystack,
                                 
std::string_view prefix);

Returns Contains(haystack, KeyRange::Prefix(prefix)).

KeyRange tensorstore::Intersect(const KeyRangeaconst KeyRangeb);

Returns the intersection of a and b.

bool tensorstore::Intersects(const KeyRangeaconst KeyRangeb);

Returns !Intersect(a, b).empty().

bool tensorstore::IntersectsPrefix(const KeyRangea,
                                   
std::string_view prefix);

Returns Intersects(a, KeyRange::Prefix(prefix)).

std::string_view tensorstore::LongestPrefix(const KeyRangerange);

Returns the longest string prefix that satisfies Contains(range, KeyRange::Prefix(prefix)).