KeySelectorPair

Namespace: FoundationDB.Client · struct

Implements: IFormattable

Represents a pair of key selectors that range 'GetKey(Begin) <= key < GetKey(End)'

Constructors

KeySelectorPair

KeySelectorPair(KeySelector beginInclusive, KeySelector endExclusive)

Create a new pair of key selectors

  • beginInclusive — Selector for key from which to start iterating
  • endExclusive — Selector for key where to stop iterating

Methods

Create

static KeySelectorPair Create(KeyRange range)

Creates a pair of key selectors using FIRST_GREATER_OR_EQUAL on both keys

static KeySelectorPair Create(KeySelector beginInclusive, KeySelector endExclusive)

Factory method for a pair of key selectors

static KeySelectorPair Create(Slice begin, Slice end)

Create a new pair of key selectors using FIRST_GREATER_OR_EQUAL on both keys

Deconstruct

void Deconstruct(out KeySelector begin, out KeySelector end)

Deconstructs this key selector pair

  • begin — Receives the Begin selector
  • end — Receives the End selector

static KeySelectorPair Head(Slice prefix, Slice cursor, bool orEqual)

Returns a pair of key selectors that will select all the keys that start with the specified prefix, up until a specific cursor

  • prefix — Common prefix of the keys that must be read (usually the containing subspace)
  • cursor — Value of the cursor, that is appended to prefix. The caller wants to read or clear any keys that are before this point
  • orEqual — If true, the key prefix + cursor will be included in the range (FIRST_GREATER_THAN); otherwise it will be skipped (FIRST_GREATER_OR_EQUAL)

Returns: Pair of selectors that will read any keys after the cursor (included if orEqual is true)

This is a common usage pattern when consuming a stream of logs or records that are indexed by a VersionStamp or a counter.

For example in a CLEAR_RANGE operation, cursor may represent the first entry to keep, in which case orEqual should be false; or it could represent the last entry to delete, in which case orEqual should be true.

StartsWith

static KeySelectorPair StartsWith(Slice prefix)

Creates a pair of key selectors that will select all the keys that start with the specified prefix

  • prefix — Common prefix of the keys that must be read

Tail

static KeySelectorPair Tail(Slice prefix, Slice cursor, bool orEqual)

Returns a pair of key selectors that will select all the keys that start with the specified prefix, and after a specific cursor

  • prefix — Common prefix of the keys that must be read (usually the containing subspace)
  • cursor — Value of the cursor, that is appended to prefix. The caller has already read any keys that are before this point, and wants to resume reading past this point
  • orEqual — If true, the key prefix + cursor will be included in the range (FIRST_GREATER_OR_EQUAL); otherwise it will be skipped (FIRST_GREATER_THAN)

Returns: Pair of selectors that will read any keys after the cursor (included if orEqual is true)

This is a common usage pattern when consuming a stream of logs or records that are indexed by a VersionStamp or a counter.

Depending on the algorithm used, cursor may represent the last read entry, in which case orEqual should be false; or it could represent the next expected entry, in which case orEqual should be true.

ToString

string ToString()

Returns a printable version of the pair of key selectors

string ToString(string format, IFormatProvider formatProvider)

Fields

Begin

readonly KeySelector Begin

Start of the range

End

readonly KeySelector End

End of the range