[][src]Struct moiradb::moiradb::MoiraDb

pub struct MoiraDb<K, V, C: ?Sized> where
    C: Debug,
    K: Debug,
    V: Debug
{ pub seq: u64, pub kv_store: HashMap<K, WriteType<V>>, pub write_set: HashSet<K>, pub outcome: TransactionResult, pub transaction: Arc<Transaction<K, C>>, // some fields omitted }

There is 1 MoiraDb per transaction.

Fields

seq: u64kv_store: HashMap<K, WriteType<V>>

A local cache of key/values, read/write

write_set: HashSet<K>

The keys we expect the transaction to write to

outcome: TransactionResult

The outcome of executing the command

transaction: Arc<Transaction<K, C>>

A reference to the transaction to execute

Implementations

impl<K, V, C> MoiraDb<K, V, C> where
    K: 'static + Send + Serialize + Eq + Hash + Clone + Debug,
    V: 'static + Send + Sync + Serialize + DeserializeOwned + Debug,
    C: Command<K, V> + Debug
[src]

pub fn new(
    transaction: Arc<Transaction<K, C>>,
    read_commands: UnboundedSender<MoiraCommand<K, V, C>>
) -> MoiraDb<K, V, C>
[src]

Construct a new instance of MoiraDb.

pub async fn read(&mut self, key: K) -> DBValue<V>[src]

Read data from the local cache or, in a case where the data is not cached locally, from the MultiVersionedStore.

pub async fn write(&mut self, key: K, value: DBValue<V>)[src]

Inserts the key and the value into the local key-value cache

pub async fn delete(&mut self, key: K)[src]

Inserts a None value for a given key, effectively deleting any stored data.

pub async fn set_outcome(self, state: TransactionResult)[src]

Sends back results to MoiraDb to commit, or abort or reschedule db writes to the backing store. Consumes this instance of MoiraDb.

When a command executes, it returns Abort, Commit, or Reschedule.

Abort stops execution.

Commit, and this transaction has only written to the originally expected values in the write set, we can commit.

But if it has written to more keys than what was originally expected, we need to reschedule it for a later commit version. Later, we will re-run the deferred future(s) and include the proper set of keys, so that the future result will be consistent.

pub async fn run_command(self) -> u64[src]

Run the command, then consume this MoiraDb in set_outcome()

impl<K, V, C> MoiraDb<K, V, C> where
    K: 'static + Send + Serialize + Eq + Hash + Clone + Debug,
    V: 'static + Send + Sync + Serialize + DeserializeOwned + Debug,
    C: Debug + MergeCommand<K, V>, 
[src]

pub async fn merge(&mut self, key: K, value: DBValue<V>)[src]

pub async fn collect(&mut self, key: K) -> DBValue<V>[src]

Trait Implementations

impl<K: Debug, V: Debug, C: Debug + ?Sized> Debug for MoiraDb<K, V, C> where
    C: Debug,
    K: Debug,
    V: Debug
[src]

Auto Trait Implementations

impl<K, V, C> !RefUnwindSafe for MoiraDb<K, V, C>[src]

impl<K, V, C: ?Sized> Send for MoiraDb<K, V, C> where
    C: Send + Sync,
    K: Send + Sync,
    V: Send + Sync
[src]

impl<K, V, C: ?Sized> Sync for MoiraDb<K, V, C> where
    C: Send + Sync,
    K: Send + Sync,
    V: Send + Sync
[src]

impl<K, V, C: ?Sized> Unpin for MoiraDb<K, V, C> where
    K: Unpin
[src]

impl<K, V, C> !UnwindSafe for MoiraDb<K, V, C>[src]

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<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<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<V, T> VZip<V> for T where
    V: MultiLane<T>,