Struct txn_types::Key [−][src]
Key type.
Keys have 2 types of binary representation - raw and encoded. The raw representation is for public interface, the encoded representation is for internal storage. We can get both representations from an instance of this type.
Orthogonal to binary representation, keys may or may not embed a timestamp, but this information is transparent to this type, the caller must use it consistently.
Implementations
impl Key
[src]
Core functions for Key
.
pub fn from_raw(key: &[u8]) -> Key
[src]
Creates a key from raw bytes.
pub fn from_raw_maybe_unbounded(key: &[u8]) -> Option<Key>
[src]
Creates a key from raw bytes but returns None if the key is an empty slice.
pub fn into_raw(self) -> Result<Vec<u8>, Error>
[src]
Gets and moves the raw representation of this key.
pub fn to_raw(&self) -> Result<Vec<u8>, Error>
[src]
Gets the raw representation of this key.
pub fn from_encoded(encoded_key: Vec<u8>) -> Key
[src]
Creates a key from encoded bytes vector.
pub fn from_encoded_slice(encoded_key: &[u8]) -> Key
[src]
Creates a key with reserved capacity for timestamp from encoded bytes slice.
pub fn as_encoded(&self) -> &Vec<u8>
[src]
Gets the encoded representation of this key.
pub fn into_encoded(self) -> Vec<u8>
[src]
Gets and moves the encoded representation of this key.
pub fn append_ts(self, ts: TimeStamp) -> Key
[src]
Creates a new key by appending a u64
timestamp to this key.
pub fn decode_ts(&self) -> Result<TimeStamp, Error>
[src]
Gets the timestamp contained in this key.
Preconditions: the caller must ensure this is actually a timestamped key.
pub fn truncate_ts(self) -> Result<Key, Error>
[src]
Creates a new key by truncating the timestamp from this key.
Preconditions: the caller must ensure this is actually a timestamped key.
pub fn split_on_ts_for(key: &[u8]) -> Result<(&[u8], TimeStamp), Error>
[src]
Split a ts encoded key, return the user key and timestamp.
pub fn truncate_ts_for(key: &[u8]) -> Result<&[u8], Error>
[src]
Extract the user key from a ts encoded key.
pub fn decode_ts_from(key: &[u8]) -> Result<TimeStamp, Error>
[src]
Decode the timestamp from a ts encoded key.
pub fn is_user_key_eq(ts_encoded_key: &[u8], user_key: &[u8]) -> bool
[src]
Whether the user key part of a ts encoded key ts_encoded_key
equals to the encoded
user key user_key
.
There is an optimization in this function, which is to compare the last 8 encoded bytes first before comparing the rest. It is because in TiDB many records are ended with an 8 byte row id and in many situations only this part is different when calling this function.
pub fn is_encoded_from(&self, raw_key: &[u8]) -> bool
[src]
Returns whether the encoded key is encoded from raw_key
.
pub fn gen_hash(&self) -> u64
[src]
TiDB uses the same hash algorithm.
Trait Implementations
impl Clone for Key
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Key
[src]
impl Display for Key
[src]
impl Eq for Key
[src]
impl Hash for Key
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Key
[src]
fn cmp(&self, other: &Key) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<Key> for Key
[src]
impl PartialOrd<Key> for Key
[src]
fn partial_cmp(&self, other: &Key) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralEq for Key
[src]
impl StructuralPartialEq for Key
[src]
Auto Trait Implementations
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnwindSafe for Key
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> Sealed<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> SendSyncUnwindSafe for T where
T: Send + Sync + UnwindSafe + ?Sized,
[src]
T: Send + Sync + UnwindSafe + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,