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
+6 -5
View File
@@ -52,9 +52,10 @@ pub trait IndexBuilder: Sized {
/// Mark `output` as fully indexed, pack its column matrices, and reopen it.
///
/// Shared tail of the `select`/`rebuild` construction paths, once their
/// partitions have been written.
fn finalize_indexed<P: AsRef<Path>>(output: P, rep: &mut Reporter) -> OKIResult<Self>;
/// Shared tail of the `select`/`rebuild`/`merge` construction paths,
/// once their partitions have been written. `sparse` selects the
/// on-disk presence-matrix format (see `pack_matrices`).
fn finalize_indexed<P: AsRef<Path>>(output: P, rep: &mut Reporter, sparse: bool) -> OKIResult<Self>;
/// Current construction state, read fresh from `index.meta` (see
/// `DevDocMD/implementation/partition_layer_cache.md`, "(11)" — no
@@ -99,12 +100,12 @@ impl IndexBuilder for KmerIndex {
Ok(idx)
}
fn finalize_indexed<P: AsRef<Path>>(output: P, rep: &mut Reporter) -> OKIResult<Self> {
fn finalize_indexed<P: AsRef<Path>>(output: P, rep: &mut Reporter, sparse: bool) -> OKIResult<Self> {
let output = output.as_ref();
let idx = KmerIndex::open(output)?;
idx.meta.mark_indexed().map_err(OKIError::Io)?;
let t_pack = Stage::start("pack");
idx.pack_matrices(false)?;
idx.pack_matrices(sparse)?;
rep.push(t_pack.stop());
Ok(idx)
}