FdbRawKey
Namespace: FoundationDB.Client · struct
Implements: IFdbKey, ISpanEncodable, ISpanFormattable, IFormattable, IEquatable<FdbRawKey>, IComparable<FdbRawKey>, IEquatable<Slice>, IComparable<Slice>, IEquatable<IFdbKey>, IComparable, IEquatable<ReadOnlySpan<byte>>, IComparable<ReadOnlySpan<byte>>, IComparisonOperators<FdbRawKey, FdbRawKey, bool>, IEqualityOperators<FdbRawKey, FdbRawKey, bool>, IComparisonOperators<FdbRawKey, Slice, bool>, IEqualityOperators<FdbRawKey, Slice, bool>
Wraps a Slice that contains a pre-encoded key in the database
Remarks
This can help in situations where the same key will be frequently used in the same transaction, and where the cost of allocating on the heap will be less than re-encoding the key over and over.
Please refrain from capturing a key in once transaction and reusing it in another. It is possible that the original subspace would be moved or re-created between both transactions, with a different prefix, which could create silent data corruption!
Properties
Span
ReadOnlySpan<byte> Span { get; }
Methods
CompareTo
int CompareTo(object obj)
int CompareTo(FdbRawKey other)
int CompareTo(Slice other)
int CompareTo(ReadOnlySpan<byte> other)
Contains
bool Contains(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
bool Contains(ReadOnlySpan<byte> 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
bool Contains<TOtherKey>(in TOtherKey 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
Equals
bool Equals(object other)
bool Equals(IFdbKey other)
bool Equals(FdbRawKey other)
bool Equals(Slice other)
bool Equals(ReadOnlySpan<byte> other)
FastCompareTo
int FastCompareTo<TOtherKey>(in TOtherKey other)
FastEqualTo
bool FastEqualTo<TOtherKey>(in TOtherKey other)
GetHashCode
int GetHashCode()
GetSuffix
Slice GetSuffix(Slice key)
Extracts the suffix from a key that is a child of the current key
key— Give that starts with the current key
Returns: Suffix part of the key
Example:
FdbKey.FromBytes("foo").GetSuffix(Slice.FromBytes("foobar")) // => `bar`
FdbKey.FromBytes("foo").GetSuffix(Slice.FromBytes("foo")) // => ``
FdbKey.FromBytes("foo").GetSuffix(Slice.FromBytes("bar")) // => throws
ReadOnlySpan<byte> GetSuffix(ReadOnlySpan<byte> key)
Extracts the suffix from a key that is a child of the current key
key— Give that starts with the current key
Returns: Suffix part of the key
Example:
FdbKey.FromBytes("foo").GetSuffix("foobar"u8) // => `bar`
FdbKey.FromBytes("foo").GetSuffix("foo"u8) // => ``
FdbKey.FromBytes("foo").GetSuffix("bar"u8) // => throws
Key
FdbTupleSuffixKey<STuple<T1>> Key<T1>(T1 item1)
FdbTupleSuffixKey<STuple<T1, T2>> Key<T1, T2>(T1 item1, T2 item2)
FdbTupleSuffixKey<STuple<T1, T2, T3>> Key<T1, T2, T3>(T1 item1, T2 item2, T3 item3)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4>> Key<T1, T2, T3, T4>(T1 item1, T2 item2, T3 item3, T4 item4)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4, T5>> Key<T1, T2, T3, T4, T5>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4, T5, T6>> Key<T1, T2, T3, T4, T5, T6>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4, T5, T6, T7>> Key<T1, T2, T3, T4, T5, T6, T7>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4, T5, T6, T7, T8>> Key<T1, T2, T3, T4, T5, T6, T7, T8>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8)
ToSlice
Slice ToSlice()
Returns the pre-encoded binary representation of this key
This method is "free" and will not cause any memory allocations
SliceOwner ToSlice(ArrayPool<byte> pool)
Returns a pooled copy of the pre-encoded binary representation of this key
ToString
string ToString()
string ToString(string format, IFormatProvider formatProvider = null)
TryEncode
bool TryEncode(Span<byte> destination, out int bytesWritten)
Encodes this instance into its equivalent binary representation in the database
destination— Destination bufferbytesWritten— Number of bytes written to the buffer
Returns: true if the operation was successful and the buffer was large enough, or false if it was too small
TryFormat
bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = null, IFormatProvider provider = null)
TryGetSizeHint
bool TryGetSizeHint(out int sizeHint)
Returns a quick estimate of the initial buffer size that would be large enough to encode this instance, in a single call to TryEncode
sizeHint— Receives an initial capacity that will satisfy almost all values. There is no guarantees that the size will be exact, and the estimate may be smaller or larger than the actual encoded size.
Returns: true if a size could be quickly computed; otherwise, false
TryGetSpan
bool TryGetSpan(out ReadOnlySpan<byte> span)
Returns the already encoded binary representation of the instance, if already available.
span— Points to the in-memory binary representation of the encoded key
Returns: true if the key has already been encoded, or it its in-memory layout is the same; otherwise, false
This is only intended to support pass-through or already encoded keys (via Slice), or when the binary representation has been cached to allow multiple uses.
TryGetSuffix
bool TryGetSuffix(Slice key, out Slice suffix)
Extracts the suffix from a key that is a child of the current key
key— Give that starts with the current keysuffix— Receives the suffix part of the key
Returns: true if key starts with this key's prefix; otherwise, false
Example:
FdbKey.FromBytes("foo").TryGetSuffix(Slice.FromBytes("foobar"), out var suffix) // => true, suffix = `bar`
FdbKey.FromBytes("foo").TryGetSuffix(Slice.FromBytes("foo"), out var suffix) // => true, suffix = ``
FdbKey.FromBytes("foo").TryGetSuffix(Slice.FromBytes("bar"), out var suffix) // => false
bool TryGetSuffix(ReadOnlySpan<byte> key, out ReadOnlySpan<byte> suffix)
Extracts the suffix from a key that is a child of the current key
key— Give that starts with the current keysuffix— Receives the suffix part of the key
Returns: true if key starts with this key's prefix; otherwise, false
Example:
FdbKey.FromBytes("foo").TryGetSuffix("foobar"u8, out var suffix) // => true, suffix = `bar`
FdbKey.FromBytes("foo").TryGetSuffix("foo"u8, out var suffix) // => true, suffix = ``
FdbKey.FromBytes("foo").TryGetSuffix("bar"u8, out var suffix) // => false
Tuple
FdbTupleSuffixKey<TTuple> Tuple<TTuple>(TTuple items)
Appends the packed elements of a tuple after the current key
items— Tuples with the items to append
Returns: New key that will append the items at the end of the current key
FdbTupleSuffixKey<STuple<T1>> Tuple<T1>(in STuple<T1> items)
FdbTupleSuffixKey<STuple<T1, T2>> Tuple<T1, T2>(in STuple<T1, T2> items)
FdbTupleSuffixKey<STuple<T1, T2, T3>> Tuple<T1, T2, T3>(in STuple<T1, T2, T3> items)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4>> Tuple<T1, T2, T3, T4>(in STuple<T1, T2, T3, T4> items)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4, T5>> Tuple<T1, T2, T3, T4, T5>(in STuple<T1, T2, T3, T4, T5> items)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4, T5, T6>> Tuple<T1, T2, T3, T4, T5, T6>(in STuple<T1, T2, T3, T4, T5, T6> items)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4, T5, T6, T7>> Tuple<T1, T2, T3, T4, T5, T6, T7>(in STuple<T1, T2, T3, T4, T5, T6, T7> items)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4, T5, T6, T7, T8>> Tuple<T1, T2, T3, T4, T5, T6, T7, T8>(in STuple<T1, T2, T3, T4, T5, T6, T7, T8> items)
FdbTupleSuffixKey<STuple<T1>> Tuple<T1>(in (T1) items)
FdbTupleSuffixKey<STuple<T1, T2>> Tuple<T1, T2>(in (T1, T2) items)
FdbTupleSuffixKey<STuple<T1, T2, T3>> Tuple<T1, T2, T3>(in (T1, T2, T3) items)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4>> Tuple<T1, T2, T3, T4>(in (T1, T2, T3, T4) items)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4, T5>> Tuple<T1, T2, T3, T4, T5>(in (T1, T2, T3, T4, T5) items)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4, T5, T6>> Tuple<T1, T2, T3, T4, T5, T6>(in (T1, T2, T3, T4, T5, T6) items)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4, T5, T6, T7>> Tuple<T1, T2, T3, T4, T5, T6, T7>(in (T1, T2, T3, T4, T5, T6, T7) items)
FdbTupleSuffixKey<STuple<T1, T2, T3, T4, T5, T6, T7, T8>> Tuple<T1, T2, T3, T4, T5, T6, T7, T8>(in (T1, T2, T3, T4, T5, T6, T7, (T8)) items)
Fields
Data
readonly Slice Data
Pre-encoded bytes for this key