Extract indexing stage into LayerBuilder with NUMA-aware scheduling

Introduce a dedicated LayerBuilder struct to orchestrate parallel layer 0 construction across partitions. The fluent API supports configurable abundance thresholds and intermediate artifact retention. Parallel execution is delegated to a NUMA-aware PartitionRunner scheduler, while progress reporting and stage timing are shifted to the command layer. A new mark_indexed method cleanly separates state tracking from orchestration by generating a completion sentinel.
This commit is contained in:
Eric Coissac committed 2026-08-21 10:20:03 +02:00
1 parent 346095b9eb
commit 4b7b3c3c1a
6 files changed
+245 -70

No files matched your search

+18 -7
View File
@@ -4,6 +4,7 @@ use std::time::Instant;
use clap::Args;
use obikindexer::algorithms::counter::Counter;
use obikindexer::algorithms::dereplicator::Dereplicator;
use obikindexer::algorithms::layer_builder::LayerBuilder;
use obikindexer::algorithms::partitionner::PartitionRouter;
use obikindex::{validate_label, GenomeInfo, IndexConfig, IndexState, KmerIndex};
use obikindex::layer::IndexMode;
@@ -328,13 +329,23 @@ pub fn run(args: IndexArgs) {
// ── Stage 3: build layered index ─────────────────────────────────────────
if idx.state() < IndexState::Indexed {
idx.build_layers(
args.min_abundance,
args.max_abundance,
args.keep_intermediate,
&mut rep,
).unwrap_or_else(|e| {
eprintln!("error: {e}");
let t = Stage::start("index");
let pb = progress_bar("index", idx.n_partitions() as u64, "partitions");
let total_kmers = LayerBuilder::new(&idx)
.min_abundance(args.min_abundance)
.max_abundance(args.max_abundance)
.keep_intermediate(args.keep_intermediate)
.run(Some(|_: Progress| pb.inc(1)))
.unwrap_or_else(|e| {
eprintln!("error: {e}");
std::process::exit(1);
});
pb.finish_and_clear();
info!("done — {total_kmers} total kmers indexed");
rep.push(t.stop());
idx.mark_indexed().unwrap_or_else(|e| {
eprintln!("error marking index done: {e}");
std::process::exit(1);
});
} else {