db-10 — Execution
What was built, in the order it was built.
1. Rust (src/rust)
Cargo.tomldeclares cratebtree10(lib) and a binarybtreectl. Edition 2021,lto = "thin",codegen-units = 1for release.src/lib.rscontains:- Constants
T = 2,MAX_KEYS = 3,MIN_KEYS = 1. Node { is_leaf, keys: Vec<(Vec<u8>, Vec<u8>)>, children: Vec<Box<Node>> }.BTreewithnew,get,insert,delete,serialize_tree,scan,len,is_empty.- Free functions
split_child,insert_nonfull,delete_from, plus the rebalance helpersborrow_from_prev,borrow_from_next,merge_children. SplitMix64PRNG (the textbook wrapping-add + xor-mul mix).run_workload(scenario, seed, ops) -> BTree.- Inline
#[cfg(test)]tests: empty-tree shape, single insert+get, insert + scan ordered, delete-of-absent returns false, delete-then-get returns None, deterministic shape under the three scenarios, scenario-cross seed independence.
- Constants
src/bin/btreectl.rs: thin arg parser (--seed,--ops,--scenario), callsrun_workload, writesserialize_tree()bytes to stdout.
2. Go (src/go)
go.modmodulegithub.com/10xdev/dse/db10, Go 1.22.btree.goports the Rust API one-for-one. Pointer-based recursion:*nodeinstead ofBox<Node>. The serializer is byte-identical to Rust's: same preorder, same little-endian encodings.btree_test.gomirrors all Rust tests.cmd/btreectl/main.gois the matching CLI.
3. C++ (src/cpp)
CMakeLists.txtbuilds:btree10_lib(static library fromsrc/btree.cc).btreectl(binary linkingbtree10_lib).test_btree10(ctest target linkingbtree10_lib).- Flags:
-Wall -Wextra -Wpedantic -Werror -O3 -DNDEBUGin Release.
src/btree.hdeclaresNode,BTree,run_workload,SplitMix64.src/btree.ccimplements them.std::unique_ptr<Node>plays the role of Rust'sBox<Node>.src/btreectl.ccis the CLI.tests/test_btree10.ccmirrors Rust's inline tests. Uses#undef NDEBUGbefore<cassert>so asserts fire under Release; neverassert(side_effect).
4. Scripts
scripts/verify.shbuilds and runs unit tests in all three languages. Exits 0 only if all three are green; prints=== OK ===.scripts/cross_test.sh:- Builds Rust/Go/C++
btreectlbinaries. - Scenario A:
btreectl --seed 42 --ops 500 --scenario insertsin each language; sha256 + size comparison. - Scenario B:
btreectl --seed 7 --ops 500 --scenario mixed; sha256 + size comparison. - Spot-check on the rust scenario-A output: assert a known key-prefix appears in the hex stream, guarding against silent-empty-output regressions.
- Print
=== ALL OK ===.
- Builds Rust/Go/C++
What was deliberately not built
- Persistence. No file I/O, no page format. db-11.
- Range scans with iterator-style streaming.
scan()returns the whole list; sufficient for tests, lazy for the spec. - Bulk-loading from a sorted input. A real B-tree would offer a fast path that builds the tree bottom-up. db-15 may revisit.
- Concurrency control. No latches, no locks. Trees of
T = 2fit comfortably in a single thread's working set and the lab has no concurrent test harness.