diff options
author | Paul Masurel <paul.masurel@gmail.com> | 2016-10-29 14:41:50 +0900 |
---|---|---|
committer | Paul Masurel <paul.masurel@gmail.com> | 2016-10-29 14:41:50 +0900 |
commit | 67b1071412a13e69cd49eb40ec6af7998b8c0f26 (patch) | |
tree | 651fa4efb958ab4ba95ca7e44f3e42aca039fddd | |
parent | 0ca78328759b1c85ca791fe849f7f3c139295012 (diff) |
issue/50 Moved segment local collection to the DocSet object.
-rw-r--r-- | src/query/query.rs | 5 | ||||
-rw-r--r-- | src/query/scorer.rs | 10 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/query/query.rs b/src/query/query.rs index 6139cac..bb70606 100644 --- a/src/query/query.rs +++ b/src/query/query.rs @@ -36,10 +36,7 @@ pub trait Query { let mut scorer = try!(weight.scorer(segment_reader)); { let _collection_timer = segment_search_timer.open("collection"); - while scorer.advance() { - let scored_doc = ScoredDoc(scorer.score(), scorer.doc()); - collector.collect(scored_doc); - } + scorer.collect(collector); } } } diff --git a/src/query/scorer.rs b/src/query/scorer.rs index 7e9f174..21d57ee 100644 --- a/src/query/scorer.rs +++ b/src/query/scorer.rs @@ -1,5 +1,6 @@ use DocSet; - +use ScoredDoc; +use collector::Collector; /// Scored `DocSet` pub trait Scorer: DocSet { @@ -8,6 +9,13 @@ pub trait Scorer: DocSet { /// /// This method will perform a bit of computation and is not cached. fn score(&self,) -> f32; + + fn collect(&mut self, collector: &mut Collector) { + while self.advance() { + let scored_doc = ScoredDoc(self.score(), self.doc()); + collector.collect(scored_doc); + } + } } |