-
-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb42e9f
commit 34b7d2b
Showing
9 changed files
with
202 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
use query::Query; | ||
use query::Weight; | ||
use query::Scorer; | ||
use core::SegmentReader; | ||
use Result; | ||
use DocSet; | ||
use Score; | ||
use DocId; | ||
use std::any::Any; | ||
use core::Searcher; | ||
|
||
#[derive(Debug)] | ||
pub struct AllQuery; | ||
|
||
impl Query for AllQuery { | ||
fn as_any(&self) -> &Any { | ||
self | ||
} | ||
|
||
fn weight(&self, searcher: &Searcher) -> Result<Box<Weight>> { | ||
Ok(box AllWeight) | ||
} | ||
} | ||
|
||
|
||
pub struct AllWeight; | ||
|
||
impl Weight for AllWeight { | ||
fn scorer<'a>(&'a self, reader: &'a SegmentReader) -> Result<Box<Scorer + 'a>> { | ||
Ok(box AllScorer { | ||
started: false, | ||
doc: 0u32, | ||
max_doc: reader.max_doc() | ||
}) | ||
} | ||
} | ||
|
||
pub struct AllScorer { | ||
started: bool, | ||
doc: DocId, | ||
max_doc: DocId, | ||
} | ||
|
||
impl DocSet for AllScorer { | ||
fn advance(&mut self) -> bool { | ||
if self.started { | ||
self.doc += 1u32; | ||
} | ||
else { | ||
self.started = true; | ||
} | ||
self.doc < self.max_doc | ||
} | ||
|
||
fn doc(&self) -> DocId { | ||
self.doc | ||
} | ||
|
||
fn size_hint(&self) -> usize { | ||
self.max_doc as usize | ||
} | ||
} | ||
|
||
impl Scorer for AllScorer { | ||
fn score(&self) -> Score { | ||
1f32 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,6 @@ where | |
self.postings.doc() | ||
} | ||
|
||
|
||
fn size_hint(&self) -> usize { | ||
self.postings.size_hint() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters