Add configurable sparsity flag to index finalization and merge CLI

Extends `KmerIndex::finalize_indexed` to accept a `sparse` boolean parameter, enabling control over whether output presence matrices are packed in a compact sparse format or stored densely. The merge command now exposes a `--dense` flag to invert this setting, defaulting to the existing sparse representation. Call sites in select and rebuild modules pass `false` to preserve current behavior. A benchmark lock file is also added for dependency tracking.
This commit is contained in:
Eric Coissac
2026-08-22 17:36:50 +02:00
parent bb380d0c7d
commit cbf6893f38
6 changed files with 23 additions and 8 deletions
+10 -1
View File
@@ -45,6 +45,7 @@ pub struct Merge<'a> {
mode: MergeMode,
force: bool,
rename_duplicates: bool,
sparse: bool,
reporter: Reporter,
on_progress: Option<Box<dyn FnMut(Progress) + Send + 'a>>,
}
@@ -57,6 +58,7 @@ impl<'a> Merge<'a> {
mode,
force: false,
rename_duplicates: false,
sparse: true,
reporter: Reporter::new(),
on_progress: None,
}
@@ -76,6 +78,13 @@ impl<'a> Merge<'a> {
self
}
/// Pack the merged output's presence matrices in the compact sparse
/// format rather than dense (default: `true`).
pub fn sparse(mut self, v: bool) -> Self {
self.sparse = v;
self
}
/// Progress callback, called once per completed partition.
pub fn on_progress(mut self, cb: impl FnMut(Progress) + Send + 'a) -> Self {
self.on_progress = Some(Box::new(cb));
@@ -322,7 +331,7 @@ impl Algorithm for Merge<'_> {
// ── Finalize: pack matrices, mark indexed, reopen ──────────────────────
let t = Stage::start("finalize");
let dst = KmerIndex::finalize_indexed(&output, &mut self.reporter)?;
let dst = KmerIndex::finalize_indexed(&output, &mut self.reporter, self.sparse)?;
self.reporter.push(t.stop());
Ok(dst)