Skip to content

Commit

Permalink
with_scaled constructor for nodegraph
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Mar 6, 2022
1 parent 2cfab65 commit d2bc8c3
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/core/src/sketch/nodegraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bitmagic::BVector;
use byteorder::{BigEndian, ByteOrder, LittleEndian, ReadBytesExt, WriteBytesExt};

use crate::prelude::*;
use crate::sketch::minhash::KmerMinHash;
use crate::sketch::minhash::{max_hash_for_scaled, KmerMinHash};
use crate::Error;
use crate::HashIntoType;

Expand Down Expand Up @@ -94,6 +94,13 @@ impl Nodegraph {
Nodegraph::new(tablesizes.as_slice(), ksize)
}

pub fn with_scaled(scaled: u64, ksize: usize) -> Nodegraph {
let max_hash = max_hash_for_scaled(scaled);
let tablesizes = vec![max_hash as usize];

Nodegraph::new(tablesizes.as_slice(), ksize)
}

pub(crate) fn count_kmer(&mut self, kmer: &[u8]) -> bool {
let h = _hash(kmer);
self.count(h)
Expand Down Expand Up @@ -675,6 +682,15 @@ mod test {
Ok(())
}

fn is_sync<T: Sync>() {}
fn is_send<T: Send>() {}

#[test]
fn assert_parallel() {
is_sync::<Nodegraph>();
is_send::<Nodegraph>();
}

#[test]
fn load_nodegraph() {
let mut filename = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
Expand Down

0 comments on commit d2bc8c3

Please sign in to comment.