Skip to content

Commit

Permalink
MRG: rename internal file & functions to use 'rocksdb' (#494)
Browse files Browse the repository at this point in the history
* rename internal file & functions to use 'rocksdb'

* fix fmt and clippy
  • Loading branch information
ctb authored Nov 4, 2024
1 parent 12eca77 commit b9acc09
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/fastmultigather.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::utils::{
consume_query_by_gather, load_collection, write_prefetch, PrefetchResult, ReportType,
};

#[allow(clippy::too_many_arguments)]
pub fn fastmultigather(
query_filepath: String,
against_filepath: String,
Expand All @@ -48,7 +49,7 @@ pub fn fastmultigather(
let scaled = match scaled {
Some(s) => s,
None => {
let scaled = query_collection.max_scaled().expect("no records!?").clone() as usize;
let scaled = *query_collection.max_scaled().expect("no records!?") as usize;
eprintln!(
"Setting scaled={} based on max scaled in query collection",
scaled
Expand Down
4 changes: 2 additions & 2 deletions src/mastiff_manygather.rs → src/fastmultigather_rocksdb.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// mastiff_manygather: mastiff-indexed version of fastmultigather.
/// fastmultigather_rocksdb: rocksdb-indexed version of fastmultigather.
use anyhow::Result;
use camino::Utf8PathBuf as PathBuf;
use rayon::prelude::*;
Expand All @@ -12,7 +12,7 @@ use crate::utils::{
csvwriter_thread, is_revindex_database, load_collection, BranchwaterGatherResult, ReportType,
};

pub fn mastiff_manygather(
pub fn fastmultigather_rocksdb(
queries_file: String,
index: PathBuf,
selection: Selection,
Expand Down
15 changes: 8 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ mod check;
mod cluster;
mod fastgather;
mod fastmultigather;
mod fastmultigather_rocksdb;
mod index;
mod manysearch;
mod manysearch_rocksdb;
mod manysketch;
mod mastiff_manygather;
mod mastiff_manysearch;
mod multisearch;
mod pairwise;
mod singlesketch;
Expand All @@ -28,6 +28,7 @@ use camino::Utf8PathBuf as PathBuf;

#[pyfunction]
#[pyo3(signature = (querylist_path, siglist_path, threshold, ksize, scaled, moltype, output_path=None, ignore_abundance=false))]
#[allow(clippy::too_many_arguments)]
fn do_manysearch(
querylist_path: String,
siglist_path: String,
Expand All @@ -45,10 +46,10 @@ fn do_manysearch(

let ignore_abundance = ignore_abundance.unwrap_or(false);

// if siglist_path is revindex, run mastiff_manysearch; otherwise run manysearch
// if siglist_path is revindex, run rocksdb manysearch; otherwise run manysearch
if is_revindex_database(&againstfile_path) {
// note: mastiff_manysearch ignores abundance automatically.
match mastiff_manysearch::mastiff_manysearch(
// note: manysearch_rocksdb ignores abundance automatically.
match manysearch_rocksdb::manysearch_rocksdb(
querylist_path,
againstfile_path,
selection,
Expand Down Expand Up @@ -133,9 +134,9 @@ fn do_fastmultigather(
let selection = build_selection(ksize, scaled, &moltype);
let allow_failed_sigpaths = true;

// if a siglist path is a revindex, run mastiff_manygather. If not, run multigather
// if a siglist path is a revindex, run rocksdb fastmultigather. If not, run multigather
if is_revindex_database(&againstfile_path) {
match mastiff_manygather::mastiff_manygather(
match fastmultigather_rocksdb::fastmultigather_rocksdb(
query_filenames,
againstfile_path,
selection.clone(),
Expand Down
4 changes: 2 additions & 2 deletions src/mastiff_manysearch.rs → src/manysearch_rocksdb.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// mastiff_manysearch: mastiff-indexed version of manysearch.
/// manysearch_rocksdb: rocksdb-indexed version of manysearch.
use anyhow::Result;
use camino::Utf8PathBuf as PathBuf;
use log::debug;
Expand All @@ -15,7 +15,7 @@ use crate::utils::{
csvwriter_thread, is_revindex_database, load_collection, ReportType, SearchResult,
};

pub fn mastiff_manysearch(
pub fn manysearch_rocksdb(
queries_path: String,
index: PathBuf,
selection: Selection,
Expand Down
2 changes: 1 addition & 1 deletion src/multisearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn multisearch(
let scaled = match selection.scaled() {
Some(s) => s,
None => {
let scaled = query_collection.max_scaled().expect("no records!?").clone() as u32;
let scaled = *query_collection.max_scaled().expect("no records!?") as u32;
eprintln!(
"Setting scaled={} based on max scaled in query collection",
scaled
Expand Down
2 changes: 1 addition & 1 deletion src/singlesketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn singlesketch(
};

// Build signature templates based on parsed parameters and detected moltype
let mut sigs = crate::manysketch::build_siginfo(&params_vec, &moltype);
let mut sigs = crate::manysketch::build_siginfo(&params_vec, moltype);

if sigs.is_empty() {
bail!("No signatures to build for the given parameters.");
Expand Down
2 changes: 1 addition & 1 deletion src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ pub fn branchwater_calculate_gather_stats(
// If abundance, calculate abund-related metrics (vs current query)
if calc_abund_stats {
// take abunds from subtracted query
let (abunds, unique_weighted_found) = match match_mh.inflated_abundances(&query) {
let (abunds, unique_weighted_found) = match match_mh.inflated_abundances(query) {
Ok((abunds, unique_weighted_found)) => (abunds, unique_weighted_found),
Err(e) => return Err(e.into()),
};
Expand Down

0 comments on commit b9acc09

Please sign in to comment.