refactor: extract index construction state tracking into extension trait
Moves pipeline state bookkeeping, including sentinel file marking and spectrum persistence, into the algorithms' run and close methods. Introduces a crate-private extension trait to satisfy Rust's orphan rule while implementing construction-only operations on KmerIndex. Updates helper function visibility for cross-crate access and removes the now-empty index_layer module.
This commit is contained in:
1 parent
31bb324752
commit
da3aa5a2cb
16 files changed
+527
-254
No files matched your search
@@ -280,12 +280,7 @@ pub fn run(args: IndexArgs) {
|
||||
});
|
||||
pb.finish_and_clear();
|
||||
rep.push(t.stop());
|
||||
drop(router); // ends the borrow of `idx` early — `PartitionRouter`'s `Drop` impl would otherwise extend it to the end of scope
|
||||
|
||||
idx.mark_scattered().unwrap_or_else(|e| {
|
||||
eprintln!("error marking scatter done: {e}");
|
||||
std::process::exit(1);
|
||||
});
|
||||
drop(router); // ends the borrow of `idx` early — `PartitionRouter`'s `Drop` impl would otherwise extend it to the end of scope (`run()` already called `close()`, which marks scatter done, internally)
|
||||
} else {
|
||||
info!("scatter already done, skipping");
|
||||
}
|
||||
@@ -305,7 +300,9 @@ pub fn run(args: IndexArgs) {
|
||||
|
||||
let t = Stage::start("count_kmer");
|
||||
let pb = progress_bar("counting", idx.n_partitions() as u64, "partitions");
|
||||
let spectrum = Counter::new(&idx)
|
||||
// `Counter::run` writes `spectrums/{label}.json` and marks count
|
||||
// done (`count.done`) internally once every partition succeeds.
|
||||
Counter::new(&idx)
|
||||
.keep_partial(args.keep_intermediate)
|
||||
.run(Some(|_: Progress| pb.inc(1)))
|
||||
.unwrap_or_else(|e| {
|
||||
@@ -314,15 +311,6 @@ pub fn run(args: IndexArgs) {
|
||||
});
|
||||
pb.finish_and_clear();
|
||||
rep.push(t.stop());
|
||||
|
||||
idx.write_spectrum(spectrum.f0, spectrum.f1, &spectrum.counts).unwrap_or_else(|e| {
|
||||
eprintln!("error: {e}");
|
||||
std::process::exit(1);
|
||||
});
|
||||
idx.mark_counted().unwrap_or_else(|e| {
|
||||
eprintln!("error marking count done: {e}");
|
||||
std::process::exit(1);
|
||||
});
|
||||
} else {
|
||||
info!("dereplicate+count already done, skipping");
|
||||
}
|
||||
@@ -343,11 +331,8 @@ pub fn run(args: IndexArgs) {
|
||||
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);
|
||||
});
|
||||
// `LayerBuilder::run` marks the index done (`index.done`) internally
|
||||
// once every partition succeeds.
|
||||
} else {
|
||||
info!("index already built, skipping");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user