Repository navigation
refactor(correct): eliminate RecordBuf duplication via raw-byte processing - #229
Conversation
…aw-byte processing Convert both the single-threaded streaming path and the multi-threaded batch pipeline path to use raw `Vec<u8>` records via `fgumi-raw-bam` exclusively, removing the duplicated RecordBuf variants of `extract_and_validate_template_umi` and `apply_correction_to_record`. - Convert `execute_single_thread_mode` from `record_bufs()` + `TemplateIterator` to raw `RawRecord` reading with manual QNAME grouping - Remove the RecordBuf else-branch from the batch pipeline `process_fn` - Simplify `CorrectProcessedBatch` and `CollectedCorrectMetrics` structs - Delete `extract_and_validate_template_umi` (RecordBuf) and `apply_correction_to_record` along with their 10 unit tests - Add characterization test for single-thread mode output correctness
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #229 +/- ##
==========================================
+ Coverage 88.18% 88.27% +0.09%
==========================================
Files 113 113
Lines 53388 53215 -173
==========================================
- Hits 47080 46977 -103
+ Misses 6308 6238 -70 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📝 WalkthroughWalkthroughThe BAM correction pipeline in 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/commands/correct.rs (1)
838-844:unwrap_or_default()silently drops records if template isn't raw-byte mode.The
debug_assert!only fires in debug builds. In release, a misconfigured pipeline would silently lose records. Using.expect()provides fail-fast behavior.Proposed fix
- let raw_records = template.into_raw_records().unwrap_or_default(); + let raw_records = template.into_raw_records().expect( + "Template should be in raw-byte mode; RecordBuf mode is no longer supported" + );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/commands/correct.rs` around lines 838 - 844, The code currently calls template.into_raw_records().unwrap_or_default() after a debug_assert!, which in release builds will silently drop records; change this to a fail-fast call (e.g., use expect or unwrap with a clear message) so misconfigured templates cannot lose data silently: replace the unwrap_or_default() call on template.into_raw_records() with expect("expected raw-byte mode template: into_raw_records returned None") (or similar) and keep the debug_assert as-is; this affects the block around template, into_raw_records, unwrap_or_default and the subsequent call to Self::extract_and_validate_template_umi_raw so the failure surfaces immediately with a descriptive message.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/commands/correct.rs`:
- Around line 838-844: The code currently calls
template.into_raw_records().unwrap_or_default() after a debug_assert!, which in
release builds will silently drop records; change this to a fail-fast call
(e.g., use expect or unwrap with a clear message) so misconfigured templates
cannot lose data silently: replace the unwrap_or_default() call on
template.into_raw_records() with expect("expected raw-byte mode template:
into_raw_records returned None") (or similar) and keep the debug_assert as-is;
this affects the block around template, into_raw_records, unwrap_or_default and
the subsequent call to Self::extract_and_validate_template_umi_raw so the
failure surfaces immediately with a descriptive message.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5d35da37-2d1e-483b-868a-06a4a3c2c874
📒 Files selected for processing (1)
src/commands/correct.rs
Summary
execute_single_thread_modefromRecordBuf+TemplateIteratorto rawRawRecordreading with manual QNAME grouping, usingextract_and_validate_template_umi_rawandapply_correction_to_rawprocess_fn(raw-byte mode is already enabled at pipeline config)CorrectProcessedBatchandCollectedCorrectMetricsby removingVec<RecordBuf>fieldsextract_and_validate_template_umi(RecordBuf variant),apply_correction_to_record, and their 10 unit testsNet: -222 lines (276 added, 498 removed)
Test Plan
test_single_thread_mode_produces_correct_outputpassescargo ci-fmtandcargo ci-lintclean