Struct tikv::storage::mvcc::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, Global>, Error>
[src][−]
Gets and moves the raw representation of this key.
pub fn to_raw(&self) -> Result<Vec<u8, Global>, Error>
[src][−]
Gets the raw representation of this key.
pub fn from_encoded(encoded_key: Vec<u8, Global>) -> 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, Global>
[src][−]
Gets the encoded representation of this key.
pub fn into_encoded(self) -> Vec<u8, Global>
[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][+]
impl Debug for Key
[src][+]
impl Display for Key
[src][+]
impl Eq for Key
[src]
impl Hash for Key
[src][+]
impl Ord for Key
[src][+]
impl PartialEq<Key> for Key
[src][+]
impl PartialOrd<Key> for Key
[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,
impl<V, W> ConvertFrom<W> for V where
W: ConvertTo<V>,
[src][+]
W: ConvertTo<V>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src][+]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
impl<T> From<T> for T
[src][+]
impl<T> Instrument for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T> Pointable for T
[src][+]
impl<T> Pointable for T
[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,
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>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src][+]
V: MultiLane<T>,