Struct tikv::storage::Storage[][src]

pub struct Storage<E: Engine, L: LockManager> {
    engine: E,
    sched: TxnScheduler<E, L>,
    read_pool: ReadPoolHandle,
    concurrency_manager: ConcurrencyManager,
    refs: Arc<AtomicUsize>,
    max_key_size: usize,
    enable_ttl: bool,
}

Storage implements transactional KV APIs and raw KV APIs on a given Engine. An Engine provides low level KV functionality. Engine has multiple implementations. When a TiKV server is running, a RaftKv will be the underlying Engine of Storage. The other two types of engines are for test purpose.

Storage is reference counted and cloning Storage will just increase the reference counter. Storage resources (i.e. threads, engine) will be released when all references are dropped.

Notice that read and write methods may not be performed over full data in most cases, i.e. when underlying engine is RaftKv, which limits data access in the range of a single region according to specified ctx parameter. However, unsafe_destroy_range is the only exception. It’s always performed on the whole TiKV.

Operations of Storage can be divided into two types: MVCC operations and raw operations. MVCC operations uses MVCC keys, which usually consist of several physical keys in different CFs. In default CF and write CF, the key will be memcomparable-encoded and append the timestamp to it, so that multiple versions can be saved at the same time. Raw operations use raw keys, which are saved directly to the engine without memcomparable- encoding and appending timestamp.

Fields

engine: Esched: TxnScheduler<E, L>read_pool: ReadPoolHandle

The thread pool used to run most read operations.

concurrency_manager: ConcurrencyManagerrefs: Arc<AtomicUsize>

How many strong references. Thread pool and workers will be stopped once there are no more references.

max_key_size: usizeenable_ttl: bool

Implementations

impl<E: Engine, L: LockManager> Storage<E, L>[src]

pub fn from_engine(
    engine: E,
    config: &Config,
    read_pool: ReadPoolHandle,
    lock_mgr: L,
    concurrency_manager: ConcurrencyManager,
    pipelined_pessimistic_lock: Arc<AtomicBool>
) -> Result<Self>
[src]

Create a Storage from given engine.

pub fn get_engine(&self) -> E[src]

Get the underlying Engine of the Storage.

pub fn get_concurrency_manager(&self) -> ConcurrencyManager[src]

pub fn dump_wait_for_entries(&self, cb: Callback)[src]

fn snapshot(
    engine: &E,
    ctx: SnapContext<'_>
) -> impl Future<Output = Result<E::Snap>>
[src]

Get a snapshot of engine.

pub fn release_snapshot(&self)[src]

pub fn get_readpool_queue_per_worker(&self) -> usize[src]

pub fn get_normal_pool_size(&self) -> usize[src]

fn with_tls_engine<F, R>(f: F) -> R where
    F: FnOnce(&E) -> R, 
[src]

fn rawkv_cf(cf: &str) -> Result<CfName>[src]

Check the given raw kv CF name. Return the CF name, or Err if given CF name is invalid. The CF name can be one of "default", "write" and "lock". If given cf is empty, CF_DEFAULT ("default") will be returned.

fn check_key_ranges(ranges: &[KeyRange], reverse: bool) -> bool[src]

Check if key range is valid

  • If reverse is true, end_key is less than start_key. end_key is the lower bound.
  • If reverse is false, end_key is greater than start_key. end_key is the upper bound.

pub fn get(
    &self,
    ctx: Context,
    key: Key,
    start_ts: TimeStamp
) -> impl Future<Output = Result<(Option<Value>, Statistics, PerfStatisticsDelta)>>
[src]

Get value of the given key from a snapshot.

Only writes that are committed before start_ts are visible.

pub fn batch_get_command<P: 'static + ResponseBatchConsumer<(Option<Vec<u8>>, Statistics, PerfStatisticsDelta)>>(
    &self,
    requests: Vec<GetRequest>,
    ids: Vec<u64>,
    consumer: P
) -> impl Future<Output = Result<()>>
[src]

Get values of a set of keys with separate context from a snapshot, return a list of Results.

Only writes that are committed before their respective start_ts are visible.

pub fn batch_get(
    &self,
    ctx: Context,
    keys: Vec<Key>,
    start_ts: TimeStamp
) -> impl Future<Output = Result<(Vec<Result<KvPair>>, Statistics, PerfStatisticsDelta)>>
[src]

Get values of a set of keys in a batch from the snapshot.

Only writes that are committed before start_ts are visible.

pub fn scan(
    &self,
    ctx: Context,
    start_key: Key,
    end_key: Option<Key>,
    limit: usize,
    sample_step: usize,
    start_ts: TimeStamp,
    key_only: bool,
    reverse_scan: bool
) -> impl Future<Output = Result<Vec<Result<KvPair>>>>
[src]

Scan keys in [start_key, end_key) up to limit keys from the snapshot.

If end_key is None, it means the upper bound is unbounded.

Only writes committed before start_ts are visible.

pub fn scan_lock(
    &self,
    ctx: Context,
    max_ts: TimeStamp,
    start_key: Option<Key>,
    end_key: Option<Key>,
    limit: usize
) -> impl Future<Output = Result<Vec<LockInfo>>>
[src]

pub fn sched_txn_command<T: StorageCallbackType>(
    &self,
    cmd: TypedCommand<T>,
    callback: Callback<T>
) -> Result<()>
[src]

pub fn delete_range(
    &self,
    ctx: Context,
    start_key: Key,
    end_key: Key,
    notify_only: bool,
    callback: Callback<()>
) -> Result<()>
[src]

Delete all keys in the range [start_key, end_key).

All keys in the range will be deleted permanently regardless of their timestamps. This means that deleted keys will not be retrievable by specifying an older timestamp. If notify_only is set, the data will not be immediately deleted, but the operation will still be replicated via Raft. This is used to notify that the data will be deleted by unsafe_destroy_range soon.

pub fn raw_get(
    &self,
    ctx: Context,
    cf: String,
    key: Vec<u8>
) -> impl Future<Output = Result<Option<Vec<u8>>>>
[src]

Get the value of a raw key.

pub fn raw_batch_get_command<P: 'static + ResponseBatchConsumer<Option<Vec<u8>>>>(
    &self,
    gets: Vec<RawGetRequest>,
    ids: Vec<u64>,
    consumer: P
) -> impl Future<Output = Result<()>>
[src]

Get the values of a set of raw keys, return a list of Results.

pub fn raw_batch_get(
    &self,
    ctx: Context,
    cf: String,
    keys: Vec<Vec<u8>>
) -> impl Future<Output = Result<Vec<Result<KvPair>>>>
[src]

Get the values of some raw keys in a batch.

pub fn raw_put(
    &self,
    ctx: Context,
    cf: String,
    key: Vec<u8>,
    value: Vec<u8>,
    ttl: u64,
    callback: Callback<()>
) -> Result<()>
[src]

Write a raw key to the storage.

pub fn raw_batch_put(
    &self,
    ctx: Context,
    cf: String,
    pairs: Vec<KvPair>,
    ttl: u64,
    callback: Callback<()>
) -> Result<()>
[src]

Write some keys to the storage in a batch.

pub fn raw_delete(
    &self,
    ctx: Context,
    cf: String,
    key: Vec<u8>,
    callback: Callback<()>
) -> Result<()>
[src]

Delete a raw key from the storage.

pub fn raw_delete_range(
    &self,
    ctx: Context,
    cf: String,
    start_key: Vec<u8>,
    end_key: Vec<u8>,
    callback: Callback<()>
) -> Result<()>
[src]

Delete all raw keys in [start_key, end_key).

pub fn raw_batch_delete(
    &self,
    ctx: Context,
    cf: String,
    keys: Vec<Vec<u8>>,
    callback: Callback<()>
) -> Result<()>
[src]

Delete some raw keys in a batch.

pub fn raw_scan(
    &self,
    ctx: Context,
    cf: String,
    start_key: Vec<u8>,
    end_key: Option<Vec<u8>>,
    limit: usize,
    key_only: bool,
    reverse_scan: bool
) -> impl Future<Output = Result<Vec<Result<KvPair>>>>
[src]

Scan raw keys in a range.

If reverse_scan is false, the range is [start_key, end_key); otherwise, the range is [end_key, start_key) and it scans from start_key and goes backwards. If end_key is None, it means unbounded.

This function scans at most limit keys.

If key_only is true, the value corresponding to the key will not be read out. Only scanned keys will be returned.

pub fn raw_batch_scan(
    &self,
    ctx: Context,
    cf: String,
    ranges: Vec<KeyRange>,
    each_limit: usize,
    key_only: bool,
    reverse_scan: bool
) -> impl Future<Output = Result<Vec<Result<KvPair>>>>
[src]

Scan raw keys in multiple ranges in a batch.

pub fn raw_get_key_ttl(
    &self,
    ctx: Context,
    cf: String,
    key: Vec<u8>
) -> impl Future<Output = Result<Option<u64>>>
[src]

Get the value of a raw key.

pub fn raw_compare_and_swap_atomic(
    &self,
    ctx: Context,
    cf: String,
    key: Vec<u8>,
    previous_value: Option<Vec<u8>>,
    value: Vec<u8>,
    ttl: u64,
    cb: Callback<(Option<Value>, bool)>
) -> Result<()>
[src]

pub fn raw_batch_put_atomic(
    &self,
    ctx: Context,
    cf: String,
    pairs: Vec<KvPair>,
    ttl: u64,
    callback: Callback<()>
) -> Result<()>
[src]

pub fn raw_batch_delete_atomic(
    &self,
    ctx: Context,
    cf: String,
    keys: Vec<Vec<u8>>,
    callback: Callback<()>
) -> Result<()>
[src]

Trait Implementations

impl<E: Engine, L: LockManager> Clone for Storage<E, L>[src]

impl<E: Engine, L: LockManager> Drop for Storage<E, L>[src]

Auto Trait Implementations

impl<E, L> !RefUnwindSafe for Storage<E, L>

impl<E, L> Send for Storage<E, L>

impl<E, L> Sync for Storage<E, L> where
    E: Sync,
    L: Sync

impl<E, L> Unpin for Storage<E, L> where
    E: Unpin

impl<E, L> !UnwindSafe for Storage<E, L>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<V, W> ConvertFrom<W> for V where
    W: ConvertTo<V>, 
[src]

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]

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> Sealed<T> for T where
    T: ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]