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
@@ -9,6 +9,7 @@
|
||||
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use obikalgorithm::Algorithm;
|
||||
use obikindex::{IndexBuilder, IndexState, KmerIndex};
|
||||
@@ -19,7 +20,7 @@ use crate::filter::KmerFilter;
|
||||
use crate::filter_partition::filter_partition;
|
||||
|
||||
pub struct Filter<'a> {
|
||||
src: &'a KmerIndex,
|
||||
src: Arc<KmerIndex>,
|
||||
output: PathBuf,
|
||||
filters: &'a [Box<dyn KmerFilter>],
|
||||
presence: bool,
|
||||
@@ -30,7 +31,7 @@ pub struct Filter<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Filter<'a> {
|
||||
pub fn new(src: &'a KmerIndex, output: impl Into<PathBuf>, filters: &'a [Box<dyn KmerFilter>]) -> Self {
|
||||
pub fn new(src: Arc<KmerIndex>, output: impl Into<PathBuf>, filters: &'a [Box<dyn KmerFilter>]) -> Self {
|
||||
Self {
|
||||
src,
|
||||
output: output.into(),
|
||||
@@ -80,7 +81,7 @@ impl Algorithm for Filter<'_> {
|
||||
type Output = KmerIndex;
|
||||
|
||||
fn run(&mut self) -> obikalgorithm::Result<KmerIndex> {
|
||||
let src = self.src;
|
||||
let src = &self.src;
|
||||
let output = self.output.clone();
|
||||
|
||||
if src.state()? != IndexState::Indexed {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
//! copied — removing kmers changes MPHF slot assignment layer-wide.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use obidebruinj::GraphDeBruijn;
|
||||
use obikidxcache::index_cache::IndexCache;
|
||||
@@ -25,7 +26,7 @@ use crate::partition_iter::FilteredPartitionIter;
|
||||
/// output from a count source.
|
||||
pub(crate) fn filter_partition(
|
||||
dst: &KmerIndex,
|
||||
src: &KmerIndex,
|
||||
src: &Arc<KmerIndex>,
|
||||
i: usize,
|
||||
filters: &[Box<dyn KmerFilter>],
|
||||
use_counts: bool,
|
||||
@@ -35,7 +36,7 @@ pub(crate) fn filter_partition(
|
||||
) -> OKIResult<()> {
|
||||
let n_genomes = src.meta().genomes().map_err(OKIError::Io)?.len();
|
||||
|
||||
let cache = IndexCache::new(src, Some(vec![i]));
|
||||
let cache = IndexCache::new(Arc::clone(src), Some(vec![i]));
|
||||
let dst_partition = dst.partition(i)?;
|
||||
let n_layers = src.partition(i)?.n_layers();
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ pub trait FilteredPartitionIter {
|
||||
) -> OKIResult<bool>;
|
||||
}
|
||||
|
||||
impl FilteredPartitionIter for IndexCache<'_> {
|
||||
impl FilteredPartitionIter for IndexCache {
|
||||
fn iter_partition_kmers(
|
||||
&self,
|
||||
part: usize,
|
||||
|
||||
Reference in new issue
Block a user