summaryrefslogtreecommitdiffstats
path: root/src/query/scorer.rs
diff options
context:
space:
mode:
authorPaul Masurel <paul.masurel@gmail.com>2018-11-30 22:46:59 +0900
committerGitHub <noreply@github.com>2018-11-30 22:46:59 +0900
commit07d87e154bdbe6dc4548ea9aef773846a8b1322e (patch)
tree3d7bb8f6bdbdf36463cc488bca8b242697f86841 /src/query/scorer.rs
parent8b0b0133ddba277b8f054e1cde7cd6b101bee095 (diff)
Collector refactoring and multithreaded search (#437)
* Split Collector into an overall Collector and a per-segment SegmentCollector. Precursor to cross-segment parallelism, and as a side benefit cleans up any per-segment fields from being Option<T> to just T. * Attempt to add MultiCollector back * working. Chained collector is broken though * Fix chained collector * Fix test * Make Weight Send+Sync for parallelization purposes * Expose parameters of RangeQuery for external usage * Removed &mut self * fixing tests * Restored TestCollectors * blop * multicollector working * chained collector working * test broken * fixing unit test * blop * blop * Blop * simplifying APi * blop * better syntax * Simplifying top_collector * refactoring * blop * Sync with master * Added multithread search * Collector refactoring * Schema::builder * CR and rustdoc * CR comments * blop * Added an executor * Sorted the segment readers in the searcher * Update searcher.rs * Fixed unit testst * changed the place where we have the sort-segment-by-count heuristic * using crossbeam::channel * inlining * Comments about panics propagating * Added unit test for executor panicking * Readded default * Removed Default impl * Added unit test for executor
Diffstat (limited to 'src/query/scorer.rs')
-rw-r--r--src/query/scorer.rs25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/query/scorer.rs b/src/query/scorer.rs
index 2c2f0cd..a2e40fa 100644
--- a/src/query/scorer.rs
+++ b/src/query/scorer.rs
@@ -1,8 +1,6 @@
-use collector::Collector;
use common::BitSet;
use docset::{DocSet, SkipResult};
use downcast;
-use fastfield::DeleteBitSet;
use std::ops::DerefMut;
use DocId;
use Score;
@@ -16,20 +14,11 @@ pub trait Scorer: downcast::Any + DocSet + 'static {
/// This method will perform a bit of computation and is not cached.
fn score(&mut self) -> Score;
- /// Consumes the complete `DocSet` and
- /// push the scored documents to the collector.
- fn collect(&mut self, collector: &mut Collector, delete_bitset_opt: Option<&DeleteBitSet>) {
- if let Some(delete_bitset) = delete_bitset_opt {
- while self.advance() {
- let doc = self.doc();
- if !delete_bitset.is_deleted(doc) {
- collector.collect(doc, self.score());
- }
- }
- } else {
- while self.advance() {
- collector.collect(self.doc(), self.score());
- }
+ /// Iterates through all of the document matched by the DocSet
+ /// `DocSet` and push the scored documents to the collector.
+ fn for_each(&mut self, callback: &mut FnMut(DocId, Score)) {
+ while self.advance() {
+ callback(self.doc(), self.score());
}
}
}
@@ -44,9 +33,9 @@ impl Scorer for Box<Scorer> {
self.deref_mut().score()
}
- fn collect(&mut self, collector: &mut Collector, delete_bitset: Option<&DeleteBitSet>) {
+ fn for_each(&mut self, callback: &mut FnMut(DocId, Score)) {
let scorer = self.deref_mut();
- scorer.collect(collector, delete_bitset);
+ scorer.for_each(callback);
}
}