2 unstable releases

0.2.0 Oct 20, 2022
0.1.0 Jul 10, 2021

#365 in Concurrency

Download history 88/week @ 2024-06-13 27/week @ 2024-06-20 25/week @ 2024-06-27 18/week @ 2024-07-04 145/week @ 2024-07-11 80/week @ 2024-07-18 56/week @ 2024-07-25 152/week @ 2024-08-01 149/week @ 2024-08-08 168/week @ 2024-08-15 8/week @ 2024-08-22 46/week @ 2024-08-29 41/week @ 2024-09-05 101/week @ 2024-09-12 245/week @ 2024-09-19 259/week @ 2024-09-26

646 downloads per month

MIT license

200KB
4K SLoC

Crate API

BzTree

BzTree(concurrent B-tree) implementation for Rust based on paper BzTree: A High-Performance Latch-free Range Index for Non-Volatile Memory.
Current implementation doesn't support non-volatile memory and supposed to be used only as in-memory(not persistent) data structure.
BzTree uses MwCAS crate to get access to multi-word CAS.

Examples

use bztree::BzTree;

let tree = BzTree::new();
let guard = crossbeam_epoch::pin();

let key1 = "key_1".to_string();
assert!(tree.insert(key1.clone(), 1, &guard));
assert!(!tree.insert(key1.clone(), 5, &guard));
tree.upsert(key1.clone(), 10, &guard);

assert!(matches!(tree.delete(&key1, &guard), Some(&10)));

let key2 = "key_2".to_string();
tree.insert(key2.clone(), 2, &guard);
assert!(tree.compute(&key2, |(_, v)| Some(v + 1), &guard));
assert!(matches!(tree.get(&key2, &guard), Some(&3)));

assert!(tree.compute(&key2, |(_, v)| {
 if *v == 3 {
     None
 } else {
     Some(v + 1)
 }
}, &guard));
assert!(matches!(tree.get(&key2, &guard), None));

Dependencies

~300KB