feat(examples): demonstrate prmi_collect_smems in the C driver - #43
Conversation
Extend the cpp_caller FFI smoke with a prmi_collect_smems block: it covers the
fused per-read SMEM collector's shape (no prior coverage) AND demonstrates the
idiomatic C calling pattern for a consumer adopting it —
- prmi_collect_opts_t setup (min_seed_len/split_len/split_width/max_mem_intv,
with max_mem_intv > 0 enabling pass 3);
- the out_cap=0 size-probe (rc -4 with *out_n = required count);
- the grow-on-(-4) retry loop (resize to *out_n, retry) — the buffer-sizing
contract a C caller must implement;
- iterating the returned prmi_smem_t[] and validating each (rid/span/occ).
Built against the cbindgen-generated prmi.h (the collect symbols land via the
#32 FFI). run_smoke.sh passes: size-probe rc=-4 needed=1, then one well-formed
SMEM spanning the reference-derived read. -Wall -Wextra clean.
Walkthrough
Changesprmi_collect_smems example driver
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/cpp_caller.cc`:
- Line 383: The span validation condition currently uses `s.n < s.m` which only
catches backwards intervals but allows zero-length spans where `s.n == s.m`.
Change the comparison operator in this validation check from `<` to `<=` so that
the condition becomes `s.n <= s.m`, which will properly reject both backwards
and zero-length intervals that are unexpected for a reference-derived read.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: d59af7de-7050-4bb7-857b-b3c7808360f1
📒 Files selected for processing (1)
examples/cpp_caller.cc
Sibling PR 2 of 2 (#41 adds the Rust
collect_gateprofiling harness). Adds the C usage example for the fused per-read SMEM collector.What
Extend the
cpp_callerFFI smoke with aprmi_collect_smemsblock that does double duty:prmi_collect_smems/prmi_collect_opts_t/prmi_smem_thad no C-side exercise; this catches FFI shape regressions in CI (theexamples/cpp_callerjob builds against the cbindgen-generatedprmi.hand runsrun_smoke.sh).prmi_collect_opts_tsetup (max_mem_intv > 0enables pass 3);out_cap = 0size-probe (rc -4with*out_n= required count);-4retry loop (resize(*out_n), retry) — the buffer-sizing contract;prmi_smem_t[]and validating each (rid/ span /occ).Verification
run_smoke.shpasses:size-probe rc=-4 needed=1, then one well-formed SMEM spanning the reference-derived 60-base read (rid=7 m=0 n=59 …),all 1 SMEMs well-formed — OK,cpp_caller exited 0 — smoke PASSED. Compiled-Wall -Wextraclean; every error path closes the index (no handle leak). Example only — no production code. Pre-PR/coderabbitai-review: 0 findings.Summary by CodeRabbit