feat(mem-search): one-shot maximal exact forward and backward match (prmi_mem_search[_backward]) - #17
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR introduces a one-shot maximal exact match query API spanning both the Rust library layer and its C-FFI interface. A new ChangesOne-shot maximal exact match queries
Sequence DiagramsequenceDiagram
participant Test
participant FFI as C FFI Layer
participant Lib as LearnedIndex
participant Oracle as Reference Oracle
Test->>FFI: prmi_mem_search(query, flags)
FFI->>Lib: mem_search(query)
Lib->>Lib: forward_spectrum_auto()
Lib-->>FFI: MemMatch {match_len, sa_start, occ}
FFI->>FFI: Conditionally write outputs based on flags
FFI-->>Test: return code + outputs
Test->>Test: Validate against Oracle reference
Test->>FFI: prmi_mem_search_backward(read, pivot, flags)
FFI->>Lib: mem_search_backward(anchor, read)
Lib->>Lib: backward_spectrum() or anchor fallback
Lib-->>FFI: MemMatch {match_len, sa_start, occ}
FFI-->>Test: return code + outputs
Test->>Test: Validate against Oracle reference
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
145de09 to
822ef64
Compare
5b273aa to
fa2e837
Compare
822ef64 to
c64daf4
Compare
fa2e837 to
dcb4286
Compare
…prmi_mem_search[_backward])
dcb4286 to
43bb1a3
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
PR #4 of the v0.2 stack (carries commit
8d17f5b). Base isfeat/v0.2-boundary-kmt(#16) — stacked on #3; merge after it. Tracked inV0.2_PR_STACK.mdrow #4.What this does
Adds the one-shot maximal-exact-match primitive on top of the spectrum engine, so a consumer can get the maximal forward (or backward) match in a single FFI call instead of walking the full breakpoint trace:
LearnedIndex::mem_search/mem_search_backward(spectrum.rs) — return the maximal (deepest) step offorward_spectrum_auto/backward_spectrum. Byte-identical by construction (they are the last breakpoint), reusing the.kmttable + occ-1 fast path unchanged.est_hintis accepted but reserved (the ISA/no-search launch lands later); ignoring a launch hint is byte-identical.prmi_mem_search/prmi_mem_search_backwardFFI (prmi-sys/src/lib.rs) — with thePRMI_MEM_WANT_INTERVALflag the SA interval is also written.mem_search ≡ maximal forward_spectrum stepandmem_search_backward ≡ maximal backward step.Cherry-picked cleanly onto #3 (no conflicts — purely additive).
Carry-forward consistency
The two new FFI entry points were authored before the #15 FFI-guard review fix, so I applied the same u64→usize
pac_num_basesguard (via the existingpacked_pac_byteshelper, returning-2) toprmi_mem_searchandprmi_mem_search_backward, and updated their-2doc enumerations — matching every other spectrum FFI entry point. The Rustmem_search/_backwardneed no extra packed-pac guard: they delegate to the already-guardedforward_spectrum_auto/backward_spectrum.Green-pass
cargo build --workspace✅cargo clippy --workspace --all-targets --all-features -- -D warnings✅cargo +nightly fmt --all -- --check✅cargo test --workspace✅ — 143 lib tests + all integration/FFI (incl.mem_search_equals_maximal_forward_step,mem_search_ffi_matches_forward_spectrum_maximal,mem_search_ffi_error_paths); only Plan-3 deferral tests remainignored.Summary by CodeRabbit
New Features
Tests