Struct tikv::storage::Storage [−][src]
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: E
sched: TxnScheduler<E, L>
read_pool: ReadPoolHandle
The thread pool used to run most read operations.
concurrency_manager: ConcurrencyManager
refs: Arc<AtomicUsize>
How many strong references. Thread pool and workers will be stopped once there are no more references.
max_key_size: usize
enable_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]
engine: E,
config: &Config,
read_pool: ReadPoolHandle,
lock_mgr: L,
concurrency_manager: ConcurrencyManager,
pipelined_pessimistic_lock: Arc<AtomicBool>
) -> Result<Self>
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]
engine: &E,
ctx: SnapContext<'_>
) -> impl Future<Output = Result<E::Snap>>
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]
F: FnOnce(&E) -> R,
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 thanstart_key
.end_key
is the lower bound. - If
reverse
is false,end_key
is greater thanstart_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]
&self,
ctx: Context,
key: Key,
start_ts: TimeStamp
) -> impl Future<Output = Result<(Option<Value>, Statistics, PerfStatisticsDelta)>>
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]
&self,
requests: Vec<GetRequest>,
ids: Vec<u64>,
consumer: P
) -> impl Future<Output = Result<()>>
Get values of a set of keys with separate context from a snapshot, return a list of Result
s.
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]
&self,
ctx: Context,
keys: Vec<Key>,
start_ts: TimeStamp
) -> impl Future<Output = Result<(Vec<Result<KvPair>>, Statistics, PerfStatisticsDelta)>>
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]
&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>>>>
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]
&self,
ctx: Context,
max_ts: TimeStamp,
start_key: Option<Key>,
end_key: Option<Key>,
limit: usize
) -> impl Future<Output = Result<Vec<LockInfo>>>
pub fn sched_txn_command<T: StorageCallbackType>(
&self,
cmd: TypedCommand<T>,
callback: Callback<T>
) -> Result<()>
[src]
&self,
cmd: TypedCommand<T>,
callback: Callback<T>
) -> Result<()>
pub fn delete_range(
&self,
ctx: Context,
start_key: Key,
end_key: Key,
notify_only: bool,
callback: Callback<()>
) -> Result<()>
[src]
&self,
ctx: Context,
start_key: Key,
end_key: Key,
notify_only: bool,
callback: Callback<()>
) -> Result<()>
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]
&self,
ctx: Context,
cf: String,
key: Vec<u8>
) -> impl Future<Output = Result<Option<Vec<u8>>>>
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]
&self,
gets: Vec<RawGetRequest>,
ids: Vec<u64>,
consumer: P
) -> impl Future<Output = Result<()>>
Get the values of a set of raw keys, return a list of Result
s.
pub fn raw_batch_get(
&self,
ctx: Context,
cf: String,
keys: Vec<Vec<u8>>
) -> impl Future<Output = Result<Vec<Result<KvPair>>>>
[src]
&self,
ctx: Context,
cf: String,
keys: Vec<Vec<u8>>
) -> impl Future<Output = Result<Vec<Result<KvPair>>>>
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]
&self,
ctx: Context,
cf: String,
key: Vec<u8>,
value: Vec<u8>,
ttl: u64,
callback: Callback<()>
) -> Result<()>
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]
&self,
ctx: Context,
cf: String,
pairs: Vec<KvPair>,
ttl: u64,
callback: Callback<()>
) -> Result<()>
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]
&self,
ctx: Context,
cf: String,
key: Vec<u8>,
callback: Callback<()>
) -> Result<()>
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]
&self,
ctx: Context,
cf: String,
start_key: Vec<u8>,
end_key: Vec<u8>,
callback: Callback<()>
) -> Result<()>
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]
&self,
ctx: Context,
cf: String,
keys: Vec<Vec<u8>>,
callback: Callback<()>
) -> Result<()>
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]
&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>>>>
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]
&self,
ctx: Context,
cf: String,
ranges: Vec<KeyRange>,
each_limit: usize,
key_only: bool,
reverse_scan: bool
) -> impl Future<Output = Result<Vec<Result<KvPair>>>>
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]
&self,
ctx: Context,
cf: String,
key: Vec<u8>
) -> impl Future<Output = Result<Option<u64>>>
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]
&self,
ctx: Context,
cf: String,
key: Vec<u8>,
previous_value: Option<Vec<u8>>,
value: Vec<u8>,
ttl: u64,
cb: Callback<(Option<Value>, bool)>
) -> Result<()>
pub fn raw_batch_put_atomic(
&self,
ctx: Context,
cf: String,
pairs: Vec<KvPair>,
ttl: u64,
callback: Callback<()>
) -> Result<()>
[src]
&self,
ctx: Context,
cf: String,
pairs: Vec<KvPair>,
ttl: u64,
callback: Callback<()>
) -> Result<()>
pub fn raw_batch_delete_atomic(
&self,
ctx: Context,
cf: String,
keys: Vec<Vec<u8>>,
callback: Callback<()>
) -> Result<()>
[src]
&self,
ctx: Context,
cf: String,
keys: Vec<Vec<u8>>,
callback: Callback<()>
) -> Result<()>
Trait Implementations
impl<E: Engine, L: LockManager> Clone for Storage<E, L>
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[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,
E: Sync,
L: Sync,
impl<E, L> Unpin for Storage<E, L> where
E: Unpin,
E: Unpin,
impl<E, L> !UnwindSafe for Storage<E, L>
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<V, W> ConvertFrom<W> for V where
W: ConvertTo<V>,
[src]
W: ConvertTo<V>,
pub fn convert_from(ctx: &mut EvalContext, from: W) -> Result<V, Error>
[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> 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> 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, 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>,