mappedbptree
A persistent, memory-mapped B+tree for Rust with a BTreeMap-like API.
Built by Claude.
Features
- File-backed storage via
mmap— data survives process restarts - Crash-safe writes with a write-ahead log (WAL) is fsynced before every
insertorremove; an interrupted write is automatically replayed on next open, leaving the tree consistent (since 0.2) - Corruption detection — every node page carries a CRC32 checksum; a partial write is detected immediately and reported as an error (since 0.2)
- Thread-safe: multiple concurrent readers, exclusive writers (
RwLock) - Zero-copy reads via
get— borrows directly from the mmap without copying - Full B+tree operations:
insert,get,get_value,remove,iter,range,clear - Auto-tuned node capacity based on system page size (4096 bytes)
Constraints
Keys (K: Ord + Pod) and values (V: Pod) must be plain-data types — fixed-size,
no heap allocations. Integers, arrays, and #[repr(C)] structs work; String and
Vec do not.
Quick start
[]
= "0.2"
use MmapBTreeBuilder;
let tree = new
.path
.build?;
tree.insert?;
assert_eq!;
tree.remove?;
for in tree.range?
License
MIT