diff options
Diffstat (limited to 'src/query/scorer.rs')
-rw-r--r-- | src/query/scorer.rs | 25 |
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); } } |