Skip to main content

reddb_server/storage/btree/
mod.rs

1//! B+ Tree with MVCC
2//!
3//! A concurrent B+ tree implementation with multi-version concurrency control.
4//!
5//! # Design
6//!
7//! ```text
8//! ┌─────────────────────────────────────────────────────────────────┐
9//! │                         B+ Tree                                  │
10//! ├─────────────────────────────────────────────────────────────────┤
11//! │                     Internal Nodes                               │
12//! │   ┌─────┬─────┬─────┐                                           │
13//! │   │ K1  │ K2  │ K3  │  Keys only (no values)                    │
14//! │   └──┬──┴──┬──┴──┬──┘                                           │
15//! │      │     │     │     Pointers to children                     │
16//! │      ▼     ▼     ▼                                              │
17//! │   ┌─────┐ ┌─────┐ ┌─────┐                                       │
18//! │   │Leaf1│ │Leaf2│ │Leaf3│  Leaf nodes (with values)             │
19//! │   └──┬──┘ └──┬──┘ └──┬──┘                                       │
20//! │      │       │       │     Sibling pointers                     │
21//! │      └───────┴───────┘                                          │
22//! └─────────────────────────────────────────────────────────────────┘
23//!
24//! MVCC Version Chain:
25//! ┌─────────────────┐     ┌─────────────────┐
26//! │ Version (txn=5) │ ──▶ │ Version (txn=3) │ ──▶ null
27//! │ value = "new"   │     │ value = "old"   │
28//! └─────────────────┘     └─────────────────┘
29//! ```
30//!
31//! # Features
32//!
33//! - Lock-free reads via MVCC snapshots
34//! - Optimistic writes with version validation
35//! - Automatic garbage collection of old versions
36//! - Support for range scans and prefix queries
37
38pub mod cursor;
39pub mod gc;
40pub mod node;
41pub mod prefetch;
42pub mod tree;
43pub mod version;
44pub mod visibility_map;
45
46pub use cursor::{Cursor, CursorDirection};
47pub use gc::{GarbageCollector, GcConfig, GcStats};
48pub use node::{InternalNode, LeafNode, Node, NodeId, NodeType};
49pub use tree::{BPlusTree, BTreeConfig, BTreeStats};
50pub use version::{Timestamp, TxnId, Version, VersionChain, VersionVisibility};