db-09 — Execution
What we built, in the order we built it.
1. Rust (src/rust)
Cargo.tomldeclares crateleveldb09(lib) and a binarydbctl.pathdependencies todb-03-write-ahead-log,db-05-lsm-memtable,db-06-sstable-format, anddb-08-block-cache-and-iterators. No network-fetched deps.src/lib.rsdefinesDb,WriteBatch,Op,OpType, and re-uses the upstream types directly (wal::Wal,memtable::{MemTable, EntryType},sstable::{SstReader, SstWriter},blockcache::{MergingIterator, SerializeStream, EntriesFromReader}).- 11 inline
#[cfg(test)]tests covering: batch round-trip, batch trailing- byte rejection, memtable put/get, delete-shadows-value, flush+memtable cleared, flush+recovery, WAL replay, newest-SST-wins, scan dedupe and tombstone drop, deterministicserialize_view, recovery with both an SST and a non-empty WAL tail. bin/dbctl.rsis a stdin-driven CLI used by the cross-language script.
2. Go (src/go)
go.modmodulegithub.com/10xdev/dse/db09withreplacedirectives pointing at the sibling labs' Go modules.db.goports the Rust API one-for-one. The WriteBatch wire format is byte-for-byte identical (u32 LE count, then per op: type byte, u32 LE klen, key, optional u32 LE vlen + value).db_test.gomirrors all 11 Rust tests.cmd/dbctl/main.gois the matching CLI.
3. C++ (src/cpp)
CMakeLists.txtcompiles upstream.ccfiles directly into local static libraries (wal_lib,memtable_lib,sstable_lib,blockcache_lib). We do notadd_subdirectory(../../../db-NN)because that would leak the upstream lab'sadd_testcalls into ourctest.src/db.handsrc/db.ccprovidedb09::Db, constructed viaDb::Open(dir) -> std::unique_ptr<Db>.Dbis non-copyable and non-movable (itsdse::wal::Walmember is itself non-copyable, and exposing moves would require fiddly forwarding for little gain in a one-process toy).- WAL move-assignment (
wal_ = dse::wal::Wal::Open(path)) is what makes the post-flush WAL reset work; this required confirming the upstream header declaresWal& operator=(Wal&&) noexcept. src/dbctl.ccandtests/test_db09.ccmirror their Rust/Go siblings. The test file uses#undef NDEBUGbefore<cassert>to guarantee asserts fire under Release builds.
4. Scripts
scripts/verify.shbuilds and runs each implementation's unit tests.scripts/cross_test.sh:- Builds Rust/Go/C++
dbctlbinaries. - Defines one canonical command script (
run.script) covering multi- flush, overwrites that land in newer SSTables, tombstones, and a non-empty WAL tail. - For each language: pipes
run.scriptintodbctl --dir db-LANG(writes + close), then reopens the same dir and pipesDUMPandDUMP_WITH_TOMBSinto separate files. Reopen forces a real WAL replay and SST reload path. - Computes sha256 of
DUMPandDUMP_WITH_TOMBSfor each language and asserts all three match. - Spot-checks the rust DUMP stream hex for the presence of the expected
final key-value bytes (
b=222,e=5) and the expected tombstone bytes (keyain DUMP_WITH_TOMBS).
- Builds Rust/Go/C++
What we deliberately didn't build
- Compaction — db-21.
- Block cache wiring inside
Db— db-08 has the cache; db-09 doesn't need it because each SSTable reader already holds the file bytes in memory. We'll plug in the LRU during db-21 when SSTable I/O becomes cold. - Bloom-filter probing — db-04 has bloom; db-21 will skip SSTables whose Bloom rejects the key.