Skip to content

Commit f476016

Browse files
barbarjstuhood
authored andcommitted
Convert BMW implementations into publicly-available PruningScorers. (#162)
As a step towards [this](paradedb/paradedb#5300), do the following: - Introduce a `PruningScorer` trait that extends a `Scorer` to support setting a threshold. - Adds a `pruning_scorer` method to the `Weight` trait, with a default implementation returning a `BasicPruningScorer`. - Moves the logic for all 3 (union, single, and intersection) block-max-wand variants into `PruningScorer` implementations so that they can be driven externally. - Has `BooleanWeight::pruning_scorer` drive the BMW choice. - Changes the visibility of the BMW scorers and they're inputs to be available to consumers of the library. In repo benchmarks show this change to be a strict improvement for BMW intersection and at most low-single-digit-percentage-points (<4%) worse for some BMW query shapes when ran on both my Mac and a dedicated Linux box. --------- Signed-off-by: RJ Barman <rjhallsted@gmail.com> Co-authored-by: Stu Hood <stuhood@paradedb.com>
1 parent 902dd08 commit f476016

13 files changed

Lines changed: 804 additions & 338 deletions

File tree

src/indexer/delete_queue.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ mod tests {
245245

246246
use super::{DeleteOperation, DeleteQueue};
247247
use crate::index::SegmentReader;
248-
use crate::query::{Explanation, Scorer, Weight};
248+
use crate::query::{Explanation, PruningScorer, Scorer, Weight};
249249
use crate::{DocId, Score};
250250

251251
struct DummyWeight;
@@ -254,6 +254,15 @@ mod tests {
254254
Err(crate::TantivyError::InternalError("dummy impl".to_owned()))
255255
}
256256

257+
fn pruning_scorer(
258+
&self,
259+
_reader: &SegmentReader,
260+
_boost: Score,
261+
_init_threshold: Score,
262+
) -> crate::Result<Box<dyn PruningScorer>> {
263+
Err(crate::TantivyError::InternalError("dummy impl".to_owned()))
264+
}
265+
257266
fn explain(&self, _reader: &SegmentReader, _doc: DocId) -> crate::Result<Explanation> {
258267
Err(crate::TantivyError::InternalError("dummy impl".to_owned()))
259268
}

src/query/boolean_query/block_wand_intersection.rs

Lines changed: 230 additions & 131 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)