Refactor: simplify logic and fix edge case

- Replaced redundant conditional checks with a single guard clause
  - Added unit test for edge case handling null input
This commit is contained in:
Eric Coissac committed 2026-04-19 21:55:48 +02:00
1 parent 2429131851
commit 41095a40d0
6 files changed
+609 -106

No files matched your search

+1 -1
View File
@@ -14,4 +14,4 @@ obiskbuilder = { path = "../obiskbuilder" }
obifastwrite = { path = "../obifastwrite" }
clap = { version = "4", features = ["derive"] }
crossbeam-channel = "0.5"
bytes = "1"
obikrope = { path = "../obikrope" }
+3 -3
View File
@@ -1,10 +1,10 @@
use std::io::{self, BufWriter, Write};
use std::thread;
use bytes::Bytes;
use clap::Args;
use crossbeam_channel::bounded;
use obifastwrite::write_scatter;
use obikrope::Rope;
use obikseq::superkmer::SuperKmer;
use obiskbuilder::SuperKmerIter;
@@ -84,7 +84,7 @@ pub fn run(args: SuperkmerArgs) {
let n_workers = args.threads.max(1);
// raw chunks (reader → workers)
let (raw_tx, raw_rx) = bounded::<Vec<Bytes>>(n_workers * 2);
let (raw_tx, raw_rx) = bounded::<Rope>(n_workers * 2);
// superkmer batches (workers → output)
let (sk_tx, sk_rx) = bounded::<Vec<(u64, SuperKmer)>>(n_workers * 2);
@@ -123,7 +123,7 @@ pub fn run(args: SuperkmerArgs) {
};
const BATCH_SIZE: usize = 10_000;
let mut batch = Vec::with_capacity(BATCH_SIZE);
for sk in SuperKmerIter::new(norm, k, m, level_max, theta) {
for sk in SuperKmerIter::new(&norm, k, m, level_max, theta) {
batch.push(sk);
if batch.len() == BATCH_SIZE {
sk_tx.send(std::mem::replace(