Skip to content

Commit

Permalink
fix underflow
Browse files Browse the repository at this point in the history
  • Loading branch information
emmaling27 committed Dec 6, 2024
1 parent 76482c6 commit acb5967
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/segment/src/index/query_estimator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub fn combine_should_estimations(
}
let element_not_hit_prob: f64 = estimations
.iter()
.map(|x| (total - x.exp) as f64 / (total as f64))
.map(|x| (total.saturating_sub(x.exp)) as f64 / (total as f64))
.product();
let element_hit_prob = 1.0 - element_not_hit_prob;
let expected_count = (element_hit_prob * (total as f64)).round() as usize;
Expand Down

0 comments on commit acb5967

Please sign in to comment.