mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-04 00:02:55 +00:00
Apply suggestions from code review
Co-authored-by: Paul Masurel <paul@quickwit.io>
This commit is contained in:
@@ -54,18 +54,15 @@ pub trait DocSet: Send {
|
||||
/// Implementations may choose to advance past the target if target does not exist.
|
||||
///
|
||||
/// DocSets that already have an efficient `seek` method don't need to implement `seek_exact`.
|
||||
/// All wapper DocSets should forward `seek_exact` to the underlying DocSet.
|
||||
/// All wrapper DocSets should forward `seek_exact` to the underlying DocSet.
|
||||
///
|
||||
/// ## API Behaviour
|
||||
/// If `seek_exact` is returning true, a call to `doc()` has to return target.
|
||||
/// If `seek_exact` is returning false, a call to `doc()` may return the previous doc,
|
||||
/// which may be lower than target.
|
||||
fn seek_exact(&mut self, target: DocId) -> bool {
|
||||
let current_doc = self.doc();
|
||||
if current_doc < target {
|
||||
self.seek(target);
|
||||
}
|
||||
self.doc() == target
|
||||
let doc = self.seek(target);
|
||||
doc == target
|
||||
}
|
||||
|
||||
/// Fills a given mutable buffer with the next doc ids from the
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
/// The estimated number of documents in the intersection.
|
||||
pub fn estimate_intersection<I>(mut docset_sizes: I, max_docs: u32) -> u32
|
||||
where I: Iterator<Item = u32> {
|
||||
if max_doc == 0u32 { return 0u32; }
|
||||
// Terms tend to be not really randomly distributed.
|
||||
// This factor is used to adjust the estimate.
|
||||
let mut co_loc_factor: f64 = 1.3;
|
||||
@@ -62,7 +63,7 @@ where I: Iterator<Item = u32> {
|
||||
|
||||
let union_estimate = (max_docs as f64 * (1.0 - not_in_any_set_prob)).round();
|
||||
|
||||
union_estimate.min(u32::MAX as f64) as u32
|
||||
union_estimate.min(max_docs as f64) as u32
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user