Expand description
B+tree (L3) — copy-on-write B+tree over the pager.
The B+tree is the data structure both the primary store (M5) and every secondary index (M7) will compose over. M4 introduces the data structure itself; M5+ wire it into typed catalog and index layers.
See docs/format.md § B+tree for the authoritative on-disk
layout this module is the reference implementation of.
§Power-of-ten posture
- Rule 1. Every tree traversal uses an explicit
heapless::Vec <PageId, MAX_BTREE_DEPTH>stack; no recursive descent. Exceeding the depth bound returnsError::BTreeDepthExceededrather than exhausting the call stack. - Rule 2. Per-node loops iterate over
key_count, which is bounded by the slot directory capacity (a function ofPAGE_SIZEknown at compile time). Range scans carry an explicitMAX_RANGE_NODESbudget. - Rule 5. Node invariants (sorted keys, level monotonicity,
slot-count bounds) are encoded as
debug_assert!s invalidate_node; release builds surface a tripped invariant asError::BTreeInvariantViolated. - Rule 7. No
unwrap/expectin the production code path. Decode errors surface asError::Corruption; semantic errors surface as one of theBTree*variants onError.
Re-exports§
pub use crate::btree::range::RangeIter;pub use crate::btree::node::decode_node;pub use crate::btree::node::encode_node;pub use crate::btree::node::max_inline_value;pub use crate::btree::node::max_key_len;pub use crate::btree::node::validate_node;pub use crate::btree::node::ChildEntry;pub use crate::btree::node::DecodedNode;pub use crate::btree::node::InternalEntry;pub use crate::btree::node::LeafEntry;pub use crate::btree::node::NodeKind;pub use crate::btree::node::NODE_HEADER_SIZE;
Modules§
- delete
- B+tree delete path with merge / borrow rebalancing.
- insert
- B+tree insert path with copy-on-write splits.
- node
- B+tree node encode / decode.
- range
- Forward range scan iterator.
Structs§
- BTree
- A B+tree handle.
Constants§
- MAX_
BTREE_ DEPTH - Maximum B+tree depth.
- MAX_
RANGE_ NODES - Maximum number of B+tree nodes visited in a single range scan.