FdbKeyExtensions
Namespace: FoundationDB.Client · class
Extension methods for working with IFdbKeyRange implementations
Methods
Bytes
static FdbSuffixKey Bytes(IKeySubspace subspace, ReadOnlySpan<byte> suffix)
Returns a key that appends a binary suffix to the subspace's prefix
subspace— Parent subspacesuffix— Binary suffix
Returns: Key that will output the subspace prefix, followed by the binary suffix
static FdbSuffixKey Bytes(IKeySubspace subspace, Slice suffix)
Returns a key that appends a binary suffix to the subspace's prefix
subspace— Parent subspacesuffix— Binary suffix
Returns: Key that will output the subspace prefix, followed by the binary suffix
static FdbSuffixKey Bytes(IKeySubspace subspace, byte[] suffix)
Returns a key that appends a binary suffix to the subspace's prefix
subspace— Parent subspacesuffix— Binary suffix
Returns: Key that will output the subspace prefix, followed by the binary suffix
static FdbSuffixKey Bytes(IKeySubspace subspace, string suffix)
Returns a key that appends a string encoded as UTF-8 to the subspace's prefix
subspace— Parent subspacesuffix— Binary suffix
Returns: Key that will output the subspace prefix, followed by the binary suffix
static FdbSuffixKey<TKey> Bytes<TKey>(TKey key, ReadOnlySpan<byte> suffix)
Returns a key that appends a binary suffix to the current key
key— Parent keysuffix— Binary suffix
Returns: Key that will append the binary suffix to the current key
Please note that this will generate a different encoding than calling with a (which uses the Tuple Encoding).
static FdbSuffixKey<TKey> Bytes<TKey>(TKey key, Slice suffix)
Returns a key that appends a binary suffix to the current key
key— Parent keysuffix— Binary suffix
Returns: Key that will append the binary suffix to the current key
Please note that this will generate a different encoding than calling with a (which uses the Tuple Encoding).
static FdbSuffixKey<TKey> Bytes<TKey>(TKey key, byte[] suffix)
Returns a key that appends a binary suffix to the current key
key— Parent keysuffix— Binary suffix
Returns: Key that will append the binary suffix to the current key
Please note that this will generate a different encoding than calling with a (which uses the Tuple Encoding).
static FdbSuffixKey<TKey> Bytes<TKey>(TKey key, string suffix)
Returns a key that appends a string encoded as UTF-8 to the current key
key— Parent keysuffix— Suffix string, encoded as UTF-8 bytes
Returns: Key that will append the binary suffix to the current key
Please note that this will generate a different encoding than calling with a (which uses the Tuple Encoding).
Contains
static bool Contains<TKey>(TKey self, Slice key)
Tests if this key is a prefix of the given key
key— Key being tested
Returns: true if key starts with the same bytes as the current key; otherwise, false
The key foobar is contained inside foo because it starts with foo, but bar is NOT contained inside foo because it does not have the same prefix.
Any key contains "itself", so foo is contained inside foo
Decode
static T1 Decode<T1>(IKeySubspace self, Slice packedKey)
Decode a key of this subspace, composed of a single element
static T1 Decode<T1>(IKeySubspace self, ReadOnlySpan<byte> packedKey)
Decode a key of this subspace, composed of a single element
static STuple<T1, T2> Decode<T1, T2>(IKeySubspace self, Slice packedKey)
Decode a key of this subspace, composed of exactly two elements
static STuple<T1, T2> Decode<T1, T2>(IKeySubspace self, ReadOnlySpan<byte> packedKey)
Decode a key of this subspace, composed of exactly two elements
static STuple<T1, T2, T3> Decode<T1, T2, T3>(IKeySubspace self, Slice packedKey)
Decode a key of this subspace, composed of exactly three elements
static STuple<T1, T2, T3> Decode<T1, T2, T3>(IKeySubspace self, ReadOnlySpan<byte> packedKey)
Decode a key of this subspace, composed of exactly three elements
static STuple<T1, T2, T3, T4> Decode<T1, T2, T3, T4>(IKeySubspace self, Slice packedKey)
Decode a key of this subspace, composed of exactly four elements
static STuple<T1, T2, T3, T4> Decode<T1, T2, T3, T4>(IKeySubspace self, ReadOnlySpan<byte> packedKey)
Decode a key of this subspace, composed of exactly four elements
static STuple<T1, T2, T3, T4, T5> Decode<T1, T2, T3, T4, T5>(IKeySubspace self, Slice packedKey)
Decode a key of this subspace, composed of exactly five elements
static STuple<T1, T2, T3, T4, T5> Decode<T1, T2, T3, T4, T5>(IKeySubspace self, ReadOnlySpan<byte> packedKey)
Decode a key of this subspace, composed of exactly five elements
static STuple<T1, T2, T3, T4, T5, T6> Decode<T1, T2, T3, T4, T5, T6>(IKeySubspace self, Slice packedKey)
Decode a key of this subspace, composed of exactly six elements
static STuple<T1, T2, T3, T4, T5, T6> Decode<T1, T2, T3, T4, T5, T6>(IKeySubspace self, ReadOnlySpan<byte> packedKey)
Decode a key of this subspace, composed of exactly six elements
static STuple<T1, T2, T3, T4, T5, T6, T7> Decode<T1, T2, T3, T4, T5, T6, T7>(IKeySubspace self, Slice packedKey)
Decode a key of this subspace, composed of exactly seven elements
static STuple<T1, T2, T3, T4, T5, T6, T7> Decode<T1, T2, T3, T4, T5, T6, T7>(IKeySubspace self, ReadOnlySpan<byte> packedKey)
Decode a key of this subspace, composed of exactly seven elements
static STuple<T1, T2, T3, T4, T5, T6, T7, T8> Decode<T1, T2, T3, T4, T5, T6, T7, T8>(IKeySubspace self, ReadOnlySpan<byte> packedKey)
Decode a key of this subspace, composed of exactly seven elements
DecodeAt
static T1 DecodeAt<T1>(IKeySubspace self, Slice packedKey, int index)
Decode a key of this subspace, and return the element at the given index
static T1 DecodeAt<T1>(IKeySubspace self, ReadOnlySpan<byte> packedKey, int index)
Decode a key of this subspace, and return the element at the given index
DecodeFirst
static T1 DecodeFirst<T1>(IKeySubspace self, Slice packedKey, int? expectedSize = null)
Decode a key of this subspace, and return only the first element without decoding the rest the key.
This method is faster than unpacking the complete key and reading only the first element.
static T1 DecodeFirst<T1>(IKeySubspace self, ReadOnlySpan<byte> packedKey, int? expectedSize = null)
Decode a key of this subspace, and return only the first element without decoding the rest the key.
This method is faster than unpacking the complete key and reading only the first element.
static (T1, T2) DecodeFirst<T1, T2>(IKeySubspace self, Slice packedKey, int? expectedSize = null)
Decode a key of this subspace, and return only the first two elements without decoding the rest the key.
This method is faster than unpacking the complete key and reading only two elements.
static (T1, T2) DecodeFirst<T1, T2>(IKeySubspace self, ReadOnlySpan<byte> packedKey, int? expectedSize = null)
Decode a key of this subspace, and return only the first two elements without decoding the rest the key.
This method is faster than unpacking the complete key and reading only two elements.
static (T1, T2, T3) DecodeFirst<T1, T2, T3>(IKeySubspace self, Slice packedKey, int? expectedSize = null)
Decode a key of this subspace, and return only the first three elements without decoding the rest the key.
This method is faster than unpacking the complete key and reading only three elements.
static (T1, T2, T3) DecodeFirst<T1, T2, T3>(IKeySubspace self, ReadOnlySpan<byte> packedKey, int? expectedSize = null)
Decode a key of this subspace, and return only the first three elements without decoding the rest the key.
This method is faster than unpacking the complete key and reading only three elements.
DecodeLast
static T1 DecodeLast<T1>(IKeySubspace self, Slice packedKey, int? expectedSize = null)
Decode a key of this subspace, and return only the last element without decoding the rest.
This method is faster than unpacking the complete key and reading only the last element.
static T1 DecodeLast<T1>(IKeySubspace self, ReadOnlySpan<byte> packedKey, int? expectedSize = null)
Decode a key of this subspace, and return only the last element without decoding the rest.
This method is faster than unpacking the complete key and reading only the last element.
static (T1, T2) DecodeLast<T1, T2>(IKeySubspace self, Slice packedKey, int? expectedSize = null)
Decode a key of this subspace, and return only the last two elements without decoding the rest.
This method is faster than unpacking the complete key and reading only the last elements.
static (T1, T2) DecodeLast<T1, T2>(IKeySubspace self, ReadOnlySpan<byte> packedKey, int? expectedSize = null)
Decode a key of this subspace, and return only the last two elements without decoding the rest.
This method is faster than unpacking the complete key and reading only the last elements.
static (T1, T2, T3) DecodeLast<T1, T2, T3>(IKeySubspace self, Slice packedKey, int? expectedSize = null)
Decode a key of this subspace, and return only the last three elements without decoding the rest.
This method is faster than unpacking the complete key and reading only the last elements.
static (T1, T2, T3) DecodeLast<T1, T2, T3>(IKeySubspace self, ReadOnlySpan<byte> packedKey, int? expectedSize = null)
Decode a key of this subspace, and return only the last three elements without decoding the rest.
This method is faster than unpacking the complete key and reading only the last elements.
static (T1, T2, T3, T4) DecodeLast<T1, T2, T3, T4>(IKeySubspace self, Slice packedKey, int? expectedSize = null)
Decode a key of this subspace, and return only the last three elements without decoding the rest.
This method is faster than unpacking the complete key and reading only the last elements.
static (T1, T2, T3, T4) DecodeLast<T1, T2, T3, T4>(IKeySubspace self, ReadOnlySpan<byte> packedKey, int? expectedSize = null)
Decode a key of this subspace, and return only the last three elements without decoding the rest.
This method is faster than unpacking the complete key and reading only the last elements.
First
static FdbSuccessorKey<FdbSubspaceKey> First(IKeySubspace subspace)
Returns a key that represents the first possible child of this subspace
subspace— Subspace to use as the source
Returns: Key that is equal to the prefix of the subspace with an extra `\x00` byte at the end
This key can be used to create ranges that match all keys that could be located in this subspace, except the subspace prefix itself.
This is equivalent to subspace.Key(null), since null is encoded as `\x00` as well.
FirstGreaterOrEqual
static FdbKeySelector<TKey> FirstGreaterOrEqual<TKey>(TKey key)
Creates a key selector that will select the first key in the database that is greater than or equal to this key
FirstGreaterThan
static FdbKeySelector<TKey> FirstGreaterThan<TKey>(TKey key)
Creates a key selector that will select the first key in the database that is greater than this key
IsSpecialKey
static bool IsSpecialKey<TKey>(TKey key)
Checks if the key is in the System keyspace (starts with `\xFF`)
IsSystemKey
static bool IsSystemKey<TKey>(TKey key)
Checks if the key is in the System keyspace (starts with `\xFF`)
Key
static FdbSubspaceKey Key(IKeySubspace subspace)
Returns the root key of this subspace
subspace— Subspace to use as the source
Returns: Key that is equal to the prefix of the subspace
This key can be used to create ranges that match all keys that could be located in this subspace
static FdbTupleKey<T1> Key<T1>(IKeySubspace subspace, T1 item1)
Returns a key under this subspace
subspace— Subspace that contains the keyitem1— value of the single element in the key
Example: // reads the document for 'user123' under this subspace var value = await tr.GetAsync(subspace.GetKey("user123"));
Please remember that if you pass a tuple as argument to this method, it will be added as an embedded tuple, which may not be what you expect! To generate a key from items already stored in a tuple, use Tuple instead.
static FdbTupleSuffixKey<TKey, STuple<T1>> Key<TKey, T1>(TKey key, T1 item1)
static FdbTupleKey<T1, T2> Key<T1, T2>(IKeySubspace subspace, T1 item1, T2 item2)
Returns a key with 2 elements under this subspace
subspace— Subspace that contains the keyitem1— value of the 1st element in the keyitem2— value of the 2nd element in the key
Example: const int DOCUMENTS = 0; // subsection that store the JSON encoded documents const int VERSIONS = 1; // subsection that store the versions of the documents tr.Set(subspace.GetKey(DOCUMENTS, "user123"), jsonBytes); tr.AtomicIncrement64(subspace.GetKey(VERSIONS, "user123"));
Please remember that if you pass a tuple as argument to this method, it will be added as an embedded tuple, which may not be what you expect! To generate a key from items already stored in a tuple, use Tuple instead.
static FdbTupleSuffixKey<TKey, STuple<T1, T2>> Key<TKey, T1, T2>(TKey key, T1 item1, T2 item2)
static FdbTupleKey<T1, T2, T3> Key<T1, T2, T3>(IKeySubspace subspace, T1 item1, T2 item2, T3 item3)
Returns a key with 3 elements under this subspace
subspace— Subspace that contains the keyitem1— value of the 1st element in the keyitem2— value of the 2nd element in the keyitem3— value of the 3rd element in the key
Example: const INDEX_BY_CITY = 2; // subsection that stores a non-unique index of users by their city name. tr.Set(subspace.GetKey(INDEX_BY_CITY, "Tokyo", "user123"), Slice.Empty)
Please remember that if you pass a tuple as argument to this method, it will be added as an embedded tuple, which may not be what you expect! To generate a key from items already stored in a tuple, use Tuple instead.
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3>> Key<TKey, T1, T2, T3>(TKey key, T1 item1, T2 item2, T3 item3)
static FdbTupleKey<T1, T2, T3, T4> Key<T1, T2, T3, T4>(IKeySubspace subspace, T1 item1, T2 item2, T3 item3, T4 item4)
Returns a key with 4 elements under this subspace
subspace— Subspace that contains the keyitem1— value of the 1st element in the keyitem2— value of the 2nd element in the keyitem3— value of the 3rd element in the keyitem4— value of the 4th element in the key
Please remember that if you pass a tuple as argument to this method, it will be added as an embedded tuple, which may not be what you expect! To generate a key from items already stored in a tuple, use Tuple instead.
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4>> Key<TKey, T1, T2, T3, T4>(TKey key, T1 item1, T2 item2, T3 item3, T4 item4)
static FdbTupleKey<T1, T2, T3, T4, T5> Key<T1, T2, T3, T4, T5>(IKeySubspace subspace, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)
Returns a key with 5 elements under this subspace
subspace— Subspace that contains the keyitem1— value of the 1st element in the keyitem2— value of the 2nd element in the keyitem3— value of the 3rd element in the keyitem4— value of the 4th element in the keyitem5— value of the 5th element in the key
Please remember that if you pass a tuple as argument to this method, it will be added as an embedded tuple, which may not be what you expect! To generate a key from items already stored in a tuple, use Tuple instead.
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4, T5>> Key<TKey, T1, T2, T3, T4, T5>(TKey key, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)
static FdbTupleKey<T1, T2, T3, T4, T5, T6> Key<T1, T2, T3, T4, T5, T6>(IKeySubspace subspace, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)
Returns a key with 6 elements under this subspace
subspace— Subspace that contains the keyitem1— value of the 1st element in the keyitem2— value of the 2nd element in the keyitem3— value of the 3rd element in the keyitem4— value of the 4th element in the keyitem5— value of the 5th element in the keyitem6— value of the 6th element in the key
Please remember that if you pass a tuple as argument to this method, it will be added as an embedded tuple, which may not be what you expect! To generate a key from items already stored in a tuple, use Tuple instead.
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4, T5, T6>> Key<TKey, T1, T2, T3, T4, T5, T6>(TKey key, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)
static FdbTupleKey<T1, T2, T3, T4, T5, T6, T7> Key<T1, T2, T3, T4, T5, T6, T7>(IKeySubspace subspace, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
Returns a key with 7 elements under this subspace
subspace— Subspace that contains the keyitem1— value of the 1st element in the keyitem2— value of the 2nd element in the keyitem3— value of the 3rd element in the keyitem4— value of the 4th element in the keyitem5— value of the 5th element in the keyitem6— value of the 6th element in the keyitem7— value of the 7th element in the key
Please remember that if you pass a tuple as argument to this method, it will be added as an embedded tuple, which may not be what you expect! To generate a key from items already stored in a tuple, use Tuple instead.
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4, T5, T6, T7>> Key<TKey, T1, T2, T3, T4, T5, T6, T7>(TKey key, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
static FdbTupleKey<T1, T2, T3, T4, T5, T6, T7, T8> Key<T1, T2, T3, T4, T5, T6, T7, T8>(IKeySubspace subspace, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8)
Returns a key with 8 elements under this subspace
subspace— Subspace that contains the keyitem1— value of the 1st element in the keyitem2— value of the 2nd element in the keyitem3— value of the 3rd element in the keyitem4— value of the 4th element in the keyitem5— value of the 5th element in the keyitem6— value of the 6th element in the keyitem7— value of the 7th element in the keyitem8— value of the 8th element in the key
Please remember that if you pass a tuple as argument to this method, it will be added as an embedded tuple, which may not be what you expect! To generate a key from items already stored in a tuple, use Tuple instead.
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4, T5, T6, T7, T8>> Key<TKey, T1, T2, T3, T4, T5, T6, T7, T8>(TKey key, T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8)
Last
static FdbLastKey<TKey> Last<TKey>(TKey key)
Returns the last legal key that is a child of this key, and that can be expressed using tuples.
key— Parent key
Returns: Key that is equal to this key, with an extra `\xFF` byte at the end
This key can be used to match all tuple-based keys that could be located under this key. If the keys could include any arbitrary binary sequence, especially if the first byte of the part of the relative part can start with `\xff`, consider using NextSibling instead.
static FdbLastKey<FdbSubspaceKey> Last(IKeySubspace subspace)
Returns the last legal key of this subspace that can be expressed using tuples.
subspace— Subspace to use as the source
Returns: Key that is equal to the prefix of the subspace with an extra `\xFF` byte at the end
This key can be used to match all tuple-based keys that could be located in this subspace. If the keys could include any arbitrary binary sequence, especially if the first byte of the part of the relative part can start with `\xff`, consider using NextSibling instead.
LastLessOrEqual
static FdbKeySelector<TKey> LastLessOrEqual<TKey>(TKey key)
Creates a key selector that will select the last key in the database that is less than or equal to this key
LastLessThan
static FdbKeySelector<TKey> LastLessThan<TKey>(TKey key)
Creates a key selector that will select the last key in the database that is less than this key
Memoize
static FdbRawKey Memoize<TKey>(TKey key)
Returns a pre-encoded version of a key
key— Key to pre-encoded
Returns: Key with a cached version of the encoded original
This key can be used multiple times without re-encoding the original
NextSibling
static FdbNextSiblingKey<TKey> NextSibling<TKey>(TKey key)
Returns a key that increments the last byte to get the key that is immediately after all the keys in the database that have the current key has a prefix (ex: `abc` => `abd`, 123 => 124)
key— Input key
Returns: Key that, when encoded into binary, will not have key as its prefix
This can be used to produce the "end" key for a range read that will return all the values under this key.
For example, tr.GetRange(subspace.GetKey(123), subspace.GetKey(123).GetNextSibling()) will be equivalent to tr.GetRange(subspace.GetKey(123), subspace.GetKey(124))
Please be careful when using this with tuples where the last elements is a String or Slice: the encoding adds an extra 0x00 bytes after the element (ex: "hello" => `\x02hello\x00`), which means that its successor (`\x02hello\x01`) will not be a valid tuple encoding, but will still be valid as an 'end' key.
It should be combined with FirstGreaterOrEqual to produce a valid 'end' selector for a range read
static FdbNextSiblingKey<FdbSubspaceKey> NextSibling(IKeySubspace subspace)
Returns a key that is the next possible key that is not a child of this subspace
subspace— Input subspace
Returns: Key that, when encoded into binary, is equal to the prefix of subspace with the last byte incremented (with carry propagation)
This can be used to produce the "end" key for a range read that will return all the values under this key, including values not generated with the Tuple Encoding (that use `\xFF` as possible byte prefix).
For example, tr.GetRange(subspace.GetKey(123), subspace.GetNextSibling()) will be equivalent to tr.GetRange(subspace.GetPrefix() + TuPack.EncodeKey(123), FdbKey.Increment(subspace.GetPrefix()))
Please note that this key technically "belongs" to another subspace, which could influence the current transaction with false "conflicts". When all keys in the subspace are produced using the Tuple Encoding, consider using Last instead.
Successor
static FdbSuccessorKey<TKey> Successor<TKey>(TKey key)
Returns a key that adds a 0x00 suffix to get the immediate successor of this key in the database (ex: `abc` => `abc\x00`)
key— Input key
Returns: Key that, when encoded into binary, will append the byte 0x00 to the representation of key
It is guaranteed that there can not be any keys between key and the returned key.
This can be used to produce the "end" key for a read or write conflict range, that will match a single key
For example, subspace.GetKey(123).GetSuccessor() will generate `\x15\x7B` + `\x00` = `\x15\x7B\x00`, which is the same as subspace.GetKey(123, null), the next possible key.
It should be combined with FirstGreaterOrEqual to produce a valid 'end' selector for a range read
ToHeadRange
static FdbKeyRange<FdbSubspaceKey, FdbTupleKey<T1>> ToHeadRange<T1>(IKeySubspace subspace, T1 cursor1)
Returns a range that matches all the children of this key that are before the specified cursor (exclusive): prefix <= k < prefix.(cursor1)
subspace— Subspace that will be used as a prefixcursor1— Value that will be used as a cursor under this key.
Returns: Range that matches all keys k under the subspace that are strictly less than subspace.Key(cursor1)
If the cursor must be included in the results, use instead
static FdbKeyRange<TKey, FdbTupleSuffixKey<TKey, STuple<T1>>> ToHeadRange<TKey, T1>(TKey key, T1 cursor1)
Returns a range that matches all the children of this key that are before the specified cursor (exclusive): key <= k < key.(cursor1)
key— Key that will be used as a prefixcursor1— Value that will be used as a cursor under this key.
Returns: Range that matches all keys k under key that are strictly less than key.Key(cursor1)
If the cursor must be included in the results, use instead
static FdbKeyRange<FdbSubspaceKey, FdbTupleKey<T1, T2>> ToHeadRange<T1, T2>(IKeySubspace subspace, T1 cursor1, T2 cursor2)
Returns a range that matches all the children of this key that are before the specified cursor (exclusive): prefix <= k < prefix.(cursor1, cursor2)
subspace— Subspace that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.
Returns: Range that matches all keys k under the subspace that are strictly less than subspace.Key(cursor1, cursor2)
If the cursor must be included in the results, use instead
static FdbKeyRange<TKey, FdbTupleSuffixKey<TKey, STuple<T1, T2>>> ToHeadRange<TKey, T1, T2>(TKey key, T1 cursor1, T2 cursor2)
Returns a range that matches all the children of this key that are before the specified cursor (exclusive): key <= k < key.(cursor1, cursor2)
key— Key that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.
Returns: Range that matches all keys k under key that are strictly less than key.Key(cursor1, cursor2)
If the cursor must be included in the results, use instead
static FdbKeyRange<FdbSubspaceKey, FdbTupleKey<T1, T2, T3>> ToHeadRange<T1, T2, T3>(IKeySubspace subspace, T1 cursor1, T2 cursor2, T3 cursor3)
Returns a range that matches all the children of this key that are before the specified cursor (exclusive): prefix <= k < prefix.(cursor1, cursor2, cursor3)
subspace— Subspace that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.cursor3— Third part of the cursor.
Returns: Range that matches all keys k under the subspace that are strictly less than subspace.Key(cursor1, cursor2, cursor3)
If the cursor must be included in the results, use instead
static FdbKeyRange<TKey, FdbTupleSuffixKey<TKey, STuple<T1, T2, T3>>> ToHeadRange<TKey, T1, T2, T3>(TKey key, T1 cursor1, T2 cursor2, T3 cursor3)
Returns a range that matches all the children of this key that are before the specified cursor (exclusive): key <= k < key.(cursor1, cursor2, cursor3)
key— Key that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.cursor3— Third part of the cursor.
Returns: Range that matches all keys k under key that are strictly less than key.Key(cursor1, cursor2, cursor3)
If the cursor must be included in the results, use instead
ToHeadRangeInclusive
static FdbKeyRange<FdbSubspaceKey, FdbTupleKey<T1>> ToHeadRangeInclusive<T1>(IKeySubspace subspace, T1 cursor1)
Returns a range that matches all the children of this key that are before the specified cursor (inclusive): prefix <= k <= prefix.(cursor1,\xFF)
subspace— Subspace that will be used as a prefixcursor1— Value that will be used as a cursor under this key.
Returns: Range that matches all keys k under the subspace that are strictly less than the next sibling of subspace.Key(cursor1)
If the cursor must be excluded from the results, use instead
static FdbKeyRange<TKey, FdbTupleSuffixKey<TKey, STuple<T1>>> ToHeadRangeInclusive<TKey, T1>(TKey key, T1 cursor1)
Returns a range that matches all the children of this key that are before the specified cursor (inclusive): key <= k <= key.(cursor1,...)
key— Key that will be used as a prefixcursor1— Value that will be used as a cursor under this key.
Returns: Range that matches all keys k under key that are strictly less than the next sibling of key.Key(cursor1)
If the cursor must be excluded from the results, use instead
static FdbKeyRange<FdbSubspaceKey, FdbTupleKey<T1, T2>> ToHeadRangeInclusive<T1, T2>(IKeySubspace subspace, T1 cursor1, T2 cursor2)
Returns a range that matches all the children of this key that are before the specified cursor (inclusive): prefix <= k <= prefix.(cursor1, cursor2, \xFF)
subspace— Subspace that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.
Returns: Range that matches all keys k under the subspace that are strictly less than the next sibling of subspace.Key(cursor1, cursor2)
If the cursor must be excluded from the results, use instead
static FdbKeyRange<TKey, FdbTupleSuffixKey<TKey, STuple<T1, T2>>> ToHeadRangeInclusive<TKey, T1, T2>(TKey key, T1 cursor1, T2 cursor2)
Returns a range that matches all the children of this key that are before the specified cursor (inclusive): key <= k <= key.(cursor1, cursor2, ...)
key— Key that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.
Returns: Range that matches all keys k under key that are strictly less than the next sibling of key.Key(cursor1, cursor2)
If the cursor must be excluded from the results, use instead
static FdbKeyRange<FdbSubspaceKey, FdbTupleKey<T1, T2, T3>> ToHeadRangeInclusive<T1, T2, T3>(IKeySubspace subspace, T1 cursor1, T2 cursor2, T3 cursor3)
Returns a range that matches all the children of this key that are before the specified cursor (inclusive): prefix <= k <= prefix.(cursor1, cursor2, cursor3, \xFF)
subspace— Subspace that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.cursor3— Third part of the cursor.
Returns: Range that matches all keys k under the subspace that are strictly less than the next sibling of subspace.Key(cursor1, cursor2, cursor3)
If the cursor must be excluded from the results, use instead
static FdbKeyRange<TKey, FdbTupleSuffixKey<TKey, STuple<T1, T2, T3>>> ToHeadRangeInclusive<TKey, T1, T2, T3>(TKey key, T1 cursor1, T2 cursor2, T3 cursor3)
Returns a range that matches all the children of this key that are before the specified cursor (inclusive): key <= k <= key.(cursor1, cursor2, cursor3, ...)
key— Key that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.cursor3— Third part of the cursor.
Returns: Range that matches all keys k under key that are strictly less than the next sibling of key.Key(cursor1, cursor2, cursor3)
If the cursor must be excluded from the results, use instead
ToKeyRange
static FdbKeyRange<TKey, TKey> ToKeyRange<TKey>(TKey key)
Returns a range that matches all children of this key that are legal tuple encodings ((...).`\x00` <= k < (...).`\xFF`)
key— Key that will be used as a prefix
Returns: Range that matches all keys that start with key (excluded) followed by one or more tuple-encoded elements
Ex: subspace.GetKey(123).ToChildrenRange() will match all the keys of the form (..., 123, ...), but not (..., 123) itself.
Please be careful when using this with tuples where the last elements is a String or Slice: the encoding adds an extra 0x00 bytes after the element (ex: "hello" => `\x02hello\x00`), which means that (..., "abc") is NOT a child of (..., "ab")
ToRange
static FdbKeyRange<TKey, TKey> ToRange<TKey>(TKey key, bool inclusive = false)
Returns a range that matches all possible children of this key
key— Key that will be used as a prefixinclusive— Iftruethe key itself will be included in the range; otherwise, the range will start immediately after this key.
Returns: Range that matches all keys that start with key (included)
Ex: subspace.GetKey(123).ToRange() will match all the keys of the form (..., 123, ...), but not (..., 123) itself.
Ex: subspace.GetKey(123).ToRange(inclusive: true) will match (..., 123) as well as all the keys of the form (..., 123, ...).
Please be careful when using this with tuples where the last elements is a String or Slice: the encoding adds an extra 0x00 bytes after the element (ex: "hello" => `\x02hello\x00`), which means that (..., "abc") is NOT a child of (..., "ab")
ToSingleRange
static FdbKeyRange<TKey, TKey> ToSingleRange<TKey>(TKey key)
Returns a range that matches only this key
key— Key that will be matched
Returns: Range that match only this key
Ex: subspace.GetKey(123).Single() will match only (..., 123), and will exclude any of its children (..., 123, ...).
ToSlice
static Slice ToSlice<TKey>(TKey key)
Encodes this key into Slice
key— Key to encode
Returns: Slice that contains the binary representation of this key
static SliceOwner ToSlice<TKey>(TKey key, ArrayPool<byte> pool)
Encodes this key into Slice, using backing buffer rented from a pool
key— Key to encodepool— Pool used to rent the buffer (Sharedisnull)
Returns: SliceOwner that contains the binary representation of this key
ToSubspace
static IKeySubspace ToSubspace<TKey>(TKey key)
Returns a new subspace that will use this key as its prefix
ToTailRange
static FdbKeyRange<FdbTupleKey<T1>, FdbSubspaceKey> ToTailRange<T1>(IKeySubspace subspace, T1 cursor1)
Returns a range that matches all the children of this subspace that are after the specified cursor (inclusive): prefix.(cursor1) <= k < prefix.`\xFF`
subspace— Parent subspace that will be used as a prefixcursor1— Value that will be used as a cursor under this key.
Returns: Range that matches all keys k under the subspace that are strictly less than key.Key(cursor1)
If the cursor must be included in the results, use instead
static FdbKeyRange<FdbTupleSuffixKey<TKey, STuple<T1>>, TKey> ToTailRange<TKey, T1>(TKey key, T1 cursor1)
Returns a range that matches all the children of this key that are after the specified cursor (inclusive): key.(cursor1) <= k < key.`\xFF`
key— Key that will be used as a prefixcursor1— Value that will be used as a cursor under this key.
Returns: Range that matches all keys k under key that are strictly less than key.Key(cursor1)
If the cursor must be included in the results, use instead
static FdbKeyRange<FdbTupleKey<T1, T2>, FdbSubspaceKey> ToTailRange<T1, T2>(IKeySubspace subspace, T1 cursor1, T2 cursor2)
Returns a range that matches all the children of this subspace that are after the specified cursor (inclusive): prefix.(cursor1,cursor2) <= k < prefix.`\xFF`
subspace— Subspace that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.
Returns: Range that matches all keys k under the subspace that are strictly less than key.Key(cursor1, cursor2)
If the cursor must be included in the results, use instead
static FdbKeyRange<FdbTupleSuffixKey<TKey, STuple<T1, T2>>, TKey> ToTailRange<TKey, T1, T2>(TKey key, T1 cursor1, T2 cursor2)
Returns a range that matches all the children of this key that are after the specified cursor (inclusive): key.(cursor1,cursor2) <= k < key.`\xFF`
key— Key that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.
Returns: Range that matches all keys k under key that are strictly less than key.Key(cursor1, cursor2)
If the cursor must be included in the results, use instead
static FdbKeyRange<FdbTupleKey<T1, T2, T3>, FdbSubspaceKey> ToTailRange<T1, T2, T3>(IKeySubspace subspace, T1 cursor1, T2 cursor2, T3 cursor3)
Returns a range that matches all the children of this subspace that are after the specified cursor (inclusive): prefix.(cursor1,cursor2,cursor3) <= k < prefix.`\xFF`
subspace— Subspace that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.cursor3— Third part of the cursor.
Returns: Range that matches all keys k under the subspace that are strictly less than key.Key(cursor1, cursor2, cursor3)
If the cursor must be included in the results, use instead
static FdbKeyRange<FdbTupleSuffixKey<TKey, STuple<T1, T2, T3>>, TKey> ToTailRange<TKey, T1, T2, T3>(TKey key, T1 cursor1, T2 cursor2, T3 cursor3)
Returns a range that matches all the children of this key that are after the specified cursor (inclusive): key.(cursor1,cursor2,cursor3) <= k < key.`\xFF`
key— Key that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.cursor3— Third part of the cursor.
Returns: Range that matches all keys k under key that are strictly less than key.Key(cursor1, cursor2, cursor3)
If the cursor must be included in the results, use instead
ToTailRangeExclusive
static FdbKeyRange<FdbTupleKey<T1>, FdbSubspaceKey> ToTailRangeExclusive<T1>(IKeySubspace subspace, T1 cursor1)
Returns a range that matches all the children of this subspace that are after the specified cursor (exclusive): prefix.(cursor1,...) < k < prefix.`\xFF`
subspace— Parent subspace that will be used as a prefixcursor1— Value that will be used as a cursor under this key.
Returns: Range that matches all keys k under the subspace that are strictly less than the next sibling of key.Key(cursor1)
If the cursor must be excluded from the results, use instead
static FdbKeyRange<FdbTupleSuffixKey<TKey, STuple<T1>>, TKey> ToTailRangeExclusive<TKey, T1>(TKey key, T1 cursor1)
Returns a range that matches all the children of this key that are after the specified cursor (exclusive): key.(cursor1,...) < k <= key.`\xFF`
key— Key that will be used as a prefixcursor1— Value that will be used as a cursor under this key.
Returns: Range that matches all keys k under key that are strictly less than the next sibling of key.Key(cursor1)
If the cursor must be excluded from the results, use instead
static FdbKeyRange<FdbTupleKey<T1, T2>, FdbSubspaceKey> ToTailRangeExclusive<T1, T2>(IKeySubspace subspace, T1 cursor1, T2 cursor2)
Returns a range that matches all the children of this subspace that are after the specified cursor (exclusive): prefix.(cursor1,cursor2,...) < k < prefix.`\xFF`
subspace— Subspace that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.
Returns: Range that matches all keys k under the subspace that are strictly less than the next sibling of key.Key(cursor1, cursor2)
If the cursor must be excluded from the results, use instead
static FdbKeyRange<FdbTupleSuffixKey<TKey, STuple<T1, T2>>, TKey> ToTailRangeExclusive<TKey, T1, T2>(TKey key, T1 cursor1, T2 cursor2)
Returns a range that matches all the children of this key that are after the specified cursor (exclusive): key.(cursor1,cursor2,...) < k <= key.`\xFF`
key— Key that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.
Returns: Range that matches all keys k under key that are strictly less than the next sibling of key.Key(cursor1, cursor2)
If the cursor must be excluded from the results, use instead
static FdbKeyRange<FdbTupleKey<T1, T2, T3>, FdbSubspaceKey> ToTailRangeExclusive<T1, T2, T3>(IKeySubspace subspace, T1 cursor1, T2 cursor2, T3 cursor3)
Returns a range that matches all the children of this subspace that are after the specified cursor (exclusive): prefix.(cursor1,cursor2,cursor3,...) < k < prefix.`\xFF`
subspace— Subspace that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.cursor3— Third part of the cursor.
Returns: Range that matches all keys k under the subspace that are strictly less than the next sibling of key.Key(cursor1, cursor2, cursor3)
If the cursor must be excluded from the results, use instead
static FdbKeyRange<FdbTupleSuffixKey<TKey, STuple<T1, T2, T3>>, TKey> ToTailRangeExclusive<TKey, T1, T2, T3>(TKey key, T1 cursor1, T2 cursor2, T3 cursor3)
Returns a range that matches all the children of this key that are after the specified cursor (exclusive): key.(cursor1,cursor2,cursor3,...) < k <= key.`\xFF`
key— Key that will be used as a prefixcursor1— First part of the cursor.cursor2— Second part of the cursor.cursor3— Third part of the cursor.
Returns: Range that matches all keys k under key that are strictly less than the next sibling of key.Key(cursor1, cursor2, cursor3)
If the cursor must be excluded from the results, use instead
Tuple
static FdbTupleKey Tuple(IKeySubspace subspace, IVarTuple items)
Returns a key that appends the packed items of the given tuple to subspace's prefix
subspace— Subspace that contains the keyitems— Elements of the key
static FdbTupleKey<T1> Tuple<T1>(IKeySubspace subspace, STuple<T1> items)
Returns a key that appends the packed items of the given tuple to subspace's prefix
subspace— Subspace that contains the keyitems— elements of the key
static FdbTupleKey<T1, T2> Tuple<T1, T2>(IKeySubspace subspace, in STuple<T1, T2> items)
Returns a key that appends the packed items of the given tuple to subspace's prefix
subspace— Subspace that contains the keyitems— elements of the key
static FdbTupleKey<T1, T2, T3> Tuple<T1, T2, T3>(IKeySubspace subspace, in STuple<T1, T2, T3> items)
Returns a key that appends the packed items of the given tuple to subspace's prefix
subspace— Subspace that contains the keyitems— elements of the key
static FdbTupleKey<T1, T2, T3, T4> Tuple<T1, T2, T3, T4>(IKeySubspace subspace, in STuple<T1, T2, T3, T4> items)
Returns a key that appends the packed items of the given tuple to subspace's prefix
subspace— Subspace that contains the keyitems— elements of the key
static FdbTupleKey<T1, T2, T3, T4, T5> Tuple<T1, T2, T3, T4, T5>(IKeySubspace subspace, in STuple<T1, T2, T3, T4, T5> items)
Returns a key that appends the packed items of the given tuple to subspace's prefix
subspace— Subspace that contains the keyitems— elements of the key
static FdbTupleKey<T1, T2, T3, T4, T5, T6> Tuple<T1, T2, T3, T4, T5, T6>(IKeySubspace subspace, in STuple<T1, T2, T3, T4, T5, T6> items)
Returns a key that appends the packed items of the given tuple to subspace's prefix
subspace— Subspace that contains the keyitems— elements of the key
static FdbTupleKey<T1, T2, T3, T4, T5, T6, T7> Tuple<T1, T2, T3, T4, T5, T6, T7>(IKeySubspace subspace, in STuple<T1, T2, T3, T4, T5, T6, T7> items)
Returns a key that appends the packed items of the given tuple to subspace's prefix
subspace— Subspace that contains the keyitems— elements of the key
static FdbTupleKey<T1, T2, T3, T4, T5, T6, T7, T8> Tuple<T1, T2, T3, T4, T5, T6, T7, T8>(IKeySubspace subspace, in STuple<T1, T2, T3, T4, T5, T6, T7, T8> items)
Returns a key that appends the packed items of the given tuple to subspace's prefix
subspace— Subspace that contains the keyitems— elements of the key
static FdbTupleKey<T1> Tuple<T1>(IKeySubspace subspace, (T1) items)
static FdbTupleKey<T1, T2> Tuple<T1, T2>(IKeySubspace subspace, in (T1, T2) items)
static FdbTupleKey<T1, T2, T3> Tuple<T1, T2, T3>(IKeySubspace subspace, in (T1, T2, T3) items)
static FdbTupleKey<T1, T2, T3, T4> Tuple<T1, T2, T3, T4>(IKeySubspace subspace, in (T1, T2, T3, T4) items)
static FdbTupleKey<T1, T2, T3, T4, T5> Tuple<T1, T2, T3, T4, T5>(IKeySubspace subspace, in (T1, T2, T3, T4, T5) items)
static FdbTupleKey<T1, T2, T3, T4, T5, T6> Tuple<T1, T2, T3, T4, T5, T6>(IKeySubspace subspace, in (T1, T2, T3, T4, T5, T6) items)
static FdbTupleKey<T1, T2, T3, T4, T5, T6, T7> Tuple<T1, T2, T3, T4, T5, T6, T7>(IKeySubspace subspace, in (T1, T2, T3, T4, T5, T6, T7) items)
static FdbTupleKey<T1, T2, T3, T4, T5, T6, T7, T8> Tuple<T1, T2, T3, T4, T5, T6, T7, T8>(IKeySubspace subspace, in (T1, T2, T3, T4, T5, T6, T7, (T8)) items)
static FdbTupleSuffixKey<TKey, TTuple> Tuple<TKey, TTuple>(TKey key, TTuple items)
Appends the packed elements of a tuple after the current key
key— Parent keyitems— Tuples with the items to append
Returns: New key that will append the items at the end of the current key
static FdbTupleSuffixKey<TKey, STuple<T1>> Tuple<TKey, T1>(TKey key, in STuple<T1> items)
static FdbTupleSuffixKey<TKey, STuple<T1, T2>> Tuple<TKey, T1, T2>(TKey key, in STuple<T1, T2> items)
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3>> Tuple<TKey, T1, T2, T3>(TKey key, in STuple<T1, T2, T3> items)
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4>> Tuple<TKey, T1, T2, T3, T4>(TKey key, in STuple<T1, T2, T3, T4> items)
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4, T5>> Tuple<TKey, T1, T2, T3, T4, T5>(TKey key, in STuple<T1, T2, T3, T4, T5> items)
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4, T5, T6>> Tuple<TKey, T1, T2, T3, T4, T5, T6>(TKey key, in STuple<T1, T2, T3, T4, T5, T6> items)
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4, T5, T6, T7>> Tuple<TKey, T1, T2, T3, T4, T5, T6, T7>(TKey key, in STuple<T1, T2, T3, T4, T5, T6, T7> items)
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4, T5, T6, T7, T8>> Tuple<TKey, T1, T2, T3, T4, T5, T6, T7, T8>(TKey key, in STuple<T1, T2, T3, T4, T5, T6, T7, T8> items)
static FdbTupleSuffixKey<TKey, STuple<T1>> Tuple<TKey, T1>(TKey key, in (T1) items)
static FdbTupleSuffixKey<TKey, STuple<T1, T2>> Tuple<TKey, T1, T2>(TKey key, in (T1, T2) items)
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3>> Tuple<TKey, T1, T2, T3>(TKey key, in (T1, T2, T3) items)
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4>> Tuple<TKey, T1, T2, T3, T4>(TKey key, in (T1, T2, T3, T4) items)
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4, T5>> Tuple<TKey, T1, T2, T3, T4, T5>(TKey key, in (T1, T2, T3, T4, T5) items)
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4, T5, T6>> Tuple<TKey, T1, T2, T3, T4, T5, T6>(TKey key, in (T1, T2, T3, T4, T5, T6) items)
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4, T5, T6, T7>> Tuple<TKey, T1, T2, T3, T4, T5, T6, T7>(TKey key, in (T1, T2, T3, T4, T5, T6, T7) items)
static FdbTupleSuffixKey<TKey, STuple<T1, T2, T3, T4, T5, T6, T7, T8>> Tuple<TKey, T1, T2, T3, T4, T5, T6, T7, T8>(TKey key, in (T1, T2, T3, T4, T5, T6, T7, (T8)) items)
Unpack
static IVarTuple Unpack(IKeySubspace self, Slice packedKey)
Decodes a binary slice into a tuple of arbitrary length
Returns: Tuple of any size (0 to N)
static SpanTuple Unpack(IKeySubspace self, ReadOnlySpan<byte> packedKey)
Decodes a binary slice into a tuple of arbitrary length
Returns: Tuple of any size (0 to N)
static SpanTuple Unpack(IKeySubspace self, ReadOnlySpan<byte> packedKey, Span<Range> buffer)
Decodes a binary key of this subspace into a tuple of arbitrary length, using a caller-supplied buffer for the element ranges