[][src]Struct rdms::mvcc::Mvcc

pub struct Mvcc<K, V> where
    K: Clone + Ord,
    V: Clone + Diff
{ /* fields omitted */ }

A Mvcc variant of LLRB index for concurrent readers, serialized writers.

Methods

impl<K, V> Mvcc<K, V> where
    K: 'static + Send + Clone + Ord + Footprint,
    V: 'static + Send + Clone + Diff + Footprint,
    <V as Diff>::D: Send
[src]

Construct new instance of Mvcc.

pub fn new<S>(name: S) -> Box<Mvcc<K, V>> where
    S: AsRef<str>, 
[src]

pub fn new_lsm<S>(name: S) -> Box<Mvcc<K, V>> where
    S: AsRef<str>, 
[src]

pub fn from_llrb(llrb_index: Llrb<K, V>) -> Box<Mvcc<K, V>>[src]

pub fn set_spinlatch(&mut self, spin: bool)[src]

Configure behaviour of spin-latch. If spin is true, calling thread shall spin until a latch is acquired or released, if false calling thread will yield to scheduler.

pub fn set_seqno(&mut self, seqno: u64)[src]

application can set the start sequence number for this index.

pub fn clone(&self) -> Box<Mvcc<K, V>>[src]

impl<K, V> Mvcc<K, V> where
    K: Clone + Ord,
    V: Clone + Diff
[src]

Maintanence API.

pub fn is_lsm(&self) -> bool[src]

Return whether this index support lsm mode.

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

Return number of entries in this instance.

pub fn to_name(&self) -> String[src]

Identify this instance. Applications can choose unique names while creating Mvcc instances.

pub fn to_seqno(&self) -> u64[src]

Return current seqno.

pub fn to_stats(&self) -> Stats[src]

Return quickly with basic statisics, only entries() method is valid with this statisics.

impl<K, V> Mvcc<K, V> where
    K: Clone + Ord + Debug,
    V: Clone + Diff
[src]

Deep walk validate of Mvcc index. Note that in addition to normal contraints to type parameter K, K-type shall also implement Debug trait.

pub fn validate(&self) -> Result<Stats>[src]

Validate LLRB tree with following rules:

  • Root node is always black in color.
  • Make sure that the maximum depth do not exceed 100.

Additionally return full statistics on the tree. Refer to [Stats] for more information.

Trait Implementations

impl<K, V> Footprint for Mvcc<K, V> where
    K: Clone + Ord,
    V: Clone + Diff
[src]

impl<K, V> Index<K, V> for Mvcc<K, V> where
    K: 'static + Send + Clone + Ord + Footprint,
    V: 'static + Send + Clone + Diff + Footprint,
    <V as Diff>::D: Send
[src]

type W = MvccWriter<K, V>

A writer type, that can ingest key-value pairs, associated with this index. Read more

type R = MvccReader<K, V>

A writer type, that can ingest key-value pairs, associated with this index. Read more

fn make_new(&self) -> Result<Box<Self>>[src]

Make a new empty index of this type, with same configuration.

fn to_reader(&mut self) -> Result<Self::R>[src]

Lockless concurrent readers are supported

fn to_writer(&mut self) -> Result<Self::W>[src]

Create a new writer handle. Multiple writers uses spin-lock to serialize write operation.

impl<K, V> Reader<K, V> for Mvcc<K, V> where
    K: Clone + Ord,
    V: Clone + Diff
[src]

Read operations on Mvcc instance.

fn get<Q: ?Sized>(&self, key: &Q) -> Result<Entry<K, V>> where
    K: Borrow<Q>,
    Q: Ord
[src]

Get the latest version for key.

fn get_with_versions<Q: ?Sized>(&self, key: &Q) -> Result<Entry<K, V>> where
    K: Borrow<Q>,
    Q: Ord
[src]

Short circuited to get().

fn iter_with_versions(&self) -> Result<IndexIter<K, V>>[src]

Short circuited to iter().

fn range_with_versions<'a, R, Q: ?Sized>(
    &'a self,
    range: R
) -> Result<IndexIter<K, V>> where
    K: Borrow<Q>,
    R: 'a + RangeBounds<Q>,
    Q: 'a + Ord
[src]

Short circuited to range().

fn reverse_with_versions<'a, R, Q: ?Sized>(
    &'a self,
    range: R
) -> Result<IndexIter<K, V>> where
    K: Borrow<Q>,
    R: 'a + RangeBounds<Q>,
    Q: 'a + Ord
[src]

Short circuited to reverse()

impl<K, V> Writer<K, V> for Mvcc<K, V> where
    K: Clone + Ord + Footprint,
    V: Clone + Diff + Footprint
[src]

Create/Update/Delete operations on Mvcc instance.

fn set(&mut self, key: K, value: V) -> Result<Option<Entry<K, V>>>[src]

Set {key, value} pair into index. If key is already present, update the value and return the previous entry, else create a new entry.

LSM mode: Add a new version for the key, perserving the old value.

fn set_cas(&mut self, key: K, value: V, cas: u64) -> Result<Option<Entry<K, V>>>[src]

Similar to set, but succeeds only when CAS matches with entry's last seqno. In other words, since seqno is unique to each mutation, we use seqno of the mutation as the CAS value. Use CAS == 0 to enforce a create operation.

LSM mode: Add a new version for the key, perserving the old value.

fn delete<Q: ?Sized>(&mut self, key: &Q) -> Result<Option<Entry<K, V>>> where
    K: Borrow<Q>,
    Q: ToOwned<Owned = K> + Ord
[src]

Delete the given key. Note that back-to-back delete for the same key shall collapse into a single delete, first delete is ingested while the rest are ignored.

LSM mode: Mark the entry as deleted along with seqno at which it deleted

NOTE: K should be borrowable as &Q and Q must be convertable to owned K. This is require in lsm mode, where owned K must be inserted into the tree.

impl<K, V> Drop for Mvcc<K, V> where
    K: Clone + Ord,
    V: Clone + Diff
[src]

impl<K, V> AsRef<Mvcc<K, V>> for MvccReader<K, V> where
    K: Clone + Ord,
    V: Clone + Diff
[src]

impl<K, V> AsMut<Mvcc<K, V>> for MvccWriter<K, V> where
    K: Clone + Ord,
    V: Clone + Diff
[src]

Auto Trait Implementations

impl<K, V> Send for Mvcc<K, V>

impl<K, V> Sync for Mvcc<K, V>

impl<K, V> Unpin for Mvcc<K, V>

impl<K, V> UnwindSafe for Mvcc<K, V> where
    K: RefUnwindSafe,
    V: RefUnwindSafe,
    <V as Diff>::D: RefUnwindSafe

impl<K, V> RefUnwindSafe for Mvcc<K, V>

Blanket Implementations

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

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

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<T> Borrow<T> for T where
    T: ?Sized
[src]

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

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