pub struct MVHashMap<K, V> { /* private fields */ }
Implementations§
source§impl<K: Hash + Clone + Eq, V> MVHashMap<K, V>
impl<K: Hash + Clone + Eq, V> MVHashMap<K, V>
sourcepub fn new_from(possible_writes: Vec<(K, Version)>) -> (Self, usize)
pub fn new_from(possible_writes: Vec<(K, Version)>) -> (Self, usize)
Create the MVHashMap structure from a list of possible writes. Each element in the list indicates a key that could potentially be modified at its given version.
Returns the MVHashMap, and the maximum number of writes that can write to one single key.
sourcepub fn write(&self, key: &K, version: Version, data: V) -> Result<(), Error>
pub fn write(&self, key: &K, version: Version, data: V) -> Result<(), Error>
Write to key
at version
.
Function will return an error if the write is not in the initial possible_writes
list.
sourcepub fn skip_if_not_set(&self, key: &K, version: Version) -> Result<(), Error>
pub fn skip_if_not_set(&self, key: &K, version: Version) -> Result<(), Error>
Skips writing to key
at version
if that entry hasn’t been assigned.
Function will return an error if the write is not in the initial possible_writes
list.
sourcepub fn skip(&self, key: &K, version: Version) -> Result<(), Error>
pub fn skip(&self, key: &K, version: Version) -> Result<(), Error>
Skips writing to key
at version
.
Function will return an error if the write is not in the initial possible_writes
list.
skip
should only be invoked when key
at version
hasn’t been assigned.
sourcepub fn read(&self, key: &K, version: Version) -> Result<&V, Option<Version>>
pub fn read(&self, key: &K, version: Version) -> Result<&V, Option<Version>>
Get the value of key
at version
.
Returns Ok(val) if such key is already assigned by previous transactions.
Returns Err(None) if version
is smaller than the write of all previous versions.
Returns Err(Some(version)) if such key is dependent on the version
-th transaction.