Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MRG: fix calculate_gather_stats threshold=0 bug #3052

Merged
merged 8 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/src/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,14 @@ pub fn calculate_gather_stats(

// If abundance, calculate abund-related metrics (vs current query)
if calc_abund_stats {
// need current downsampled query here to get f_unique_weighted
// take abunds from subtracted 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);
}
};

n_unique_weighted_found = unique_weighted_found as usize;
sum_total_weighted_found = sum_weighted_found + n_unique_weighted_found;
f_unique_weighted = n_unique_weighted_found as f64 / total_weighted_hashes as f64;
Expand Down
4 changes: 4 additions & 0 deletions src/core/src/index/revindex/disk_revindex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ impl RevIndexOps for RevIndex {

let (dataset_id, size) = counter.k_most_common_ordered(1)[0];
match_size = if size >= threshold { size } else { break };
// handle special case where threshold was set to 0
if match_size == 0 {
break;
}

// this should downsample mh for us
let match_sig = self.collection.sig_for_dataset(dataset_id)?;
Expand Down
Loading