refactor: Shift KmerIndex ownership to Arc for thread-safe sharing
Replaces lifetime-bound references with runtime reference counting across multiple crates. This enables safe concurrent access across parallel workers without explicit cloning or manual lifetime management. Introduces the `query` and `utils` CLI commands in obikmer2, along with supporting modules for batch processing, sparse indexing, sliding-window findere logic, and output formatting. Updates dependency manifests and aligns test suites with the new ownership model.
This commit is contained in:
1 parent
10a0909687
commit
bd7729b095
31 files changed
+1689
-178
No files matched your search
@@ -8,6 +8,7 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::sync::Arc;
|
||||
|
||||
use obidebruinj::GraphDeBruijn;
|
||||
use obikfilter::FilteredPartitionIter;
|
||||
@@ -24,7 +25,7 @@ pub trait IndexCompact {
|
||||
fn compact_layers(&self, on_partition: impl Fn() + Send + Sync) -> OKIResult<()>;
|
||||
}
|
||||
|
||||
impl IndexCompact for KmerIndex {
|
||||
impl IndexCompact for Arc<KmerIndex> {
|
||||
fn compact_layers(&self, on_partition: impl Fn() + Send + Sync) -> OKIResult<()> {
|
||||
let n_genomes = self.meta().genomes().map_err(OKIError::Io)?.len();
|
||||
let use_counts = self.meta().config.with_counts;
|
||||
@@ -47,7 +48,7 @@ impl IndexCompact for KmerIndex {
|
||||
/// existing layers in place. No-op if the partition already has one layer
|
||||
/// (or none).
|
||||
fn compact_partition(
|
||||
idx: &KmerIndex,
|
||||
idx: &Arc<KmerIndex>,
|
||||
i: usize,
|
||||
use_counts: bool,
|
||||
n_genomes: usize,
|
||||
@@ -63,7 +64,7 @@ fn compact_partition(
|
||||
// ── Read: every layer's kmers, combined — no filter, nothing removed ──
|
||||
let mut survivors: HashMap<CanonicalKmer, Box<[u32]>> = HashMap::new();
|
||||
{
|
||||
let cache = IndexCache::new(idx, Some(vec![i]));
|
||||
let cache = IndexCache::new(Arc::clone(idx), Some(vec![i]));
|
||||
cache.iter_partition_kmers(i, use_counts, n_genomes, &[], |kmer, row| {
|
||||
survivors.insert(kmer, row);
|
||||
true
|
||||
|
||||
Reference in new issue
Block a user