DawgCore<U, V>Make DynamicDawg<V> / DynamicDawgChar<V> / DynamicDawgU64<V> thin
wrappers over crate::dawg_core::DawgCore<U, V>. Delete the
duplicate BloomFilter / NodeSignature / DynamicDawgInner
declarations local to each variant.
The audit estimated 2-3 weeks. Verified by inspection:
src/dynamic_dawg.rs — 2321 LOC. Local declarations at line 98
(BloomFilter), line 110 (NodeSignature), line 1114
(DynamicDawgInner). Method count: ~25 public methods + ~20 internal
helpers.src/dynamic_dawg_char.rs — 2148 LOC. Identical layout, char-keyed.src/dynamic_dawg_u64.rs — smaller (~600 LOC) but its u64-keyed
algorithms are subtly different (Vec edge format).Each method needs to be migrated to use DawgCore's generic helpers
while preserving public API. Per-impl test verification required at
every step (existing test suite is large).
dawg_core::DawgCore<U, V> already has the full method
surface needed:
pub fn new() -> Selfpub fn from_terms<I, S>(terms: I) -> Self where I: IntoIterator<Item = S>, S: AsRef<str>insert(&self, term: &str) -> boolinsert_with_value(&self, term: &str, value: V) -> boolremove(&self, term: &str) -> boolcontains(&self, term: &str) -> boolget_value(&self, term: &str) -> Option<V>compact(&self), needs_compaction(&self), minimize(&self)DawgCore is missing methods, extend it FIRST (commit each
addition individually). Tests in dawg_core/tests.rs.Each step is its own commit.
Run rg -n 'pub fn|pub struct|impl' src/dawg_core.rs > /tmp/dawg_core_api.txt.
Cross-reference with the public methods on DynamicDawg<V>. Identify gaps.
Add methods to DawgCore<U, V>. One commit per method or small group.
DynamicDawg<V> to DawgCore<u8, V>DawgCore<u8, V>.BloomFilter, NodeSignature, DynamicDawgInner
declarations.cargo test --all-features -- dynamic_dawg:: at each step.DynamicDawgChar<V> to DawgCore<char, V>Same pattern as Step 3.
DynamicDawgU64<V> to DawgCore<u64, V>Trickier due to the u64-keyed differences. May require extending
DawgCore's edge-storage abstraction.
cargo test --all-features clean.cargo bench --bench dawg_* — no > 2% regression vs pre-migration
baseline. Record numbers in docs/benchmarks/tier1-ledger.md.dynamic_dawg.rs: ~2321 → ~400 LOC (thin wrapper)dynamic_dawg_char.rs: ~2148 → ~400 LOCdynamic_dawg_u64.rs: ~600 → ~300 LOCDynamicDawgU64's u64 algorithm has subtly different invariants
(8-byte-aligned chunks, padding). May need DawgCore to gain a
generic edge-storage trait before this works cleanly.DawgCore's shared bloom filter uses the same constants.find_or_create_suffix cache is currently disabled (B4); if
someone re-enables it in DawgCore, the char and u64 variants get
it "for free" — verify the invariant holds for all three before
enabling.Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |