pub struct BptreeMap<K, V>{ /* private fields */ }Expand description
A concurrently readable map based on a modified B+Tree structure.
This structure can be used in locations where you would otherwise us
RwLock<BTreeMap> or Mutex<BTreeMap>.
Generally, the concurrent HashMap is a better choice unless you require ordered key storage.
This is a concurrently readable structure, meaning it has transactional properties. Writers are serialised (one after the other), and readers can exist in parallel with stable views of the structure at a point in time.
This is achieved through the use of COW or MVCC. As a write occurs, subsets of the tree are cloned into the writer thread and then committed later. This may cause memory usage to increase in exchange for a gain in concurrent behaviour.
Transactions can be rolled-back (aborted) without penalty by dropping
the BptreeMapWriteTxn without calling commit().
Implementations§
Source§impl<K: Clone + Ord + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> BptreeMap<K, V>
impl<K: Clone + Ord + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> BptreeMap<K, V>
Source§impl<K: Clone + Ord + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> BptreeMap<K, V>
impl<K: Clone + Ord + Debug + Sync + Send + 'static, V: Clone + Sync + Send + 'static> BptreeMap<K, V>
Sourcepub fn read(&self) -> BptreeMapReadTxn<'_, K, V>
pub fn read(&self) -> BptreeMapReadTxn<'_, K, V>
Initiate a read transaction for the tree, concurrent to any other readers or writers.
Sourcepub fn write(&self) -> BptreeMapWriteTxn<'_, K, V>
pub fn write(&self) -> BptreeMapWriteTxn<'_, K, V>
Initiate a write transaction for the tree, exclusive to this writer, and concurrently to all existing reads.