mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-05-29 22:50:41 +00:00
Cargo clippy
This commit is contained in:
@@ -74,13 +74,11 @@ impl DocSet for BitSetDocSet {
|
||||
self.cursor_tinybitset = self.cursor_tinybitset.intersect(greater_filter);
|
||||
if !self.advance() {
|
||||
SkipResult::End
|
||||
} else if self.doc() == target {
|
||||
SkipResult::Reached
|
||||
} else {
|
||||
if self.doc() == target {
|
||||
SkipResult::Reached
|
||||
} else {
|
||||
debug_assert!(self.doc() > target);
|
||||
SkipResult::OverStep
|
||||
}
|
||||
debug_assert!(self.doc() > target);
|
||||
SkipResult::OverStep
|
||||
}
|
||||
}
|
||||
Ordering::Equal => loop {
|
||||
|
||||
@@ -21,18 +21,14 @@ where
|
||||
if scorers.len() == 1 {
|
||||
scorers.into_iter().next().unwrap() //< we checked the size beforehands
|
||||
} else {
|
||||
if scorers.iter().all(|scorer| {
|
||||
let is_all_term_queries = scorers.iter().all(|scorer| {
|
||||
let scorer_ref: &Scorer = scorer.borrow();
|
||||
Downcast::<TermScorer>::is_type(scorer_ref)
|
||||
}) {
|
||||
});
|
||||
if is_all_term_queries {
|
||||
let scorers: Vec<TermScorer> = scorers
|
||||
.into_iter()
|
||||
.map(|scorer| {
|
||||
*Downcast::<TermScorer>::downcast(scorer).expect(
|
||||
"downcasting should not have failed, we\
|
||||
checked in advance that the type were correct.",
|
||||
)
|
||||
})
|
||||
.map(|scorer| *Downcast::<TermScorer>::downcast(scorer).unwrap())
|
||||
.collect();
|
||||
let scorer: Box<Scorer> = box Union::<TermScorer, TScoreCombiner>::from(scorers);
|
||||
scorer
|
||||
@@ -61,7 +57,7 @@ impl BooleanWeight {
|
||||
reader: &SegmentReader,
|
||||
) -> Result<Box<Scorer>> {
|
||||
let mut per_occur_scorers: HashMap<Occur, Vec<Box<Scorer>>> = HashMap::new();
|
||||
for &(ref occur, ref subweight) in self.weights.iter() {
|
||||
for &(ref occur, ref subweight) in &self.weights {
|
||||
let sub_scorer: Box<Scorer> = subweight.scorer(reader)?;
|
||||
per_occur_scorers
|
||||
.entry(*occur)
|
||||
@@ -82,18 +78,14 @@ impl BooleanWeight {
|
||||
if scorers.len() == 1 {
|
||||
scorers.into_iter().next().unwrap()
|
||||
} else {
|
||||
if scorers.iter().all(|scorer| {
|
||||
let is_all_term_queries = scorers.iter().all(|scorer| {
|
||||
let scorer_ref: &Scorer = scorer.borrow();
|
||||
Downcast::<TermScorer>::is_type(scorer_ref)
|
||||
}) {
|
||||
});
|
||||
if is_all_term_queries {
|
||||
let scorers: Vec<TermScorer> = scorers
|
||||
.into_iter()
|
||||
.map(|scorer| {
|
||||
*Downcast::<TermScorer>::downcast(scorer).expect(
|
||||
"downcasting should not have failed, we\
|
||||
checked in advance that the type were correct.",
|
||||
)
|
||||
})
|
||||
.map(|scorer| *Downcast::<TermScorer>::downcast(scorer).unwrap())
|
||||
.collect();
|
||||
let scorer: Box<Scorer> = box Intersection::from(scorers);
|
||||
scorer
|
||||
|
||||
@@ -121,19 +121,19 @@ impl DocSet for PhraseScorer {
|
||||
|
||||
fn skip_next(&mut self, target: DocId) -> SkipResult {
|
||||
if self.intersection_docset.skip_next(target) == SkipResult::End {
|
||||
SkipResult::End
|
||||
} else if self.phrase_match() {
|
||||
return SkipResult::End;
|
||||
}
|
||||
if self.phrase_match() {
|
||||
if self.doc() == target {
|
||||
SkipResult::Reached
|
||||
return SkipResult::Reached;
|
||||
} else {
|
||||
SkipResult::OverStep
|
||||
return SkipResult::OverStep;
|
||||
}
|
||||
}
|
||||
if self.advance() {
|
||||
SkipResult::OverStep
|
||||
} else {
|
||||
if self.advance() {
|
||||
SkipResult::OverStep
|
||||
} else {
|
||||
SkipResult::End
|
||||
}
|
||||
SkipResult::End
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,15 +150,15 @@ impl RangeWeight {
|
||||
{
|
||||
use std::collections::Bound::*;
|
||||
let mut term_stream_builder = term_dict.range();
|
||||
term_stream_builder = match &self.left_bound {
|
||||
&Included(ref term_val) => term_stream_builder.ge(term_val),
|
||||
&Excluded(ref term_val) => term_stream_builder.gt(term_val),
|
||||
&Unbounded => term_stream_builder,
|
||||
term_stream_builder = match self.left_bound {
|
||||
Included(ref term_val) => term_stream_builder.ge(term_val),
|
||||
Excluded(ref term_val) => term_stream_builder.gt(term_val),
|
||||
Unbounded => term_stream_builder,
|
||||
};
|
||||
term_stream_builder = match &self.right_bound {
|
||||
&Included(ref term_val) => term_stream_builder.le(term_val),
|
||||
&Excluded(ref term_val) => term_stream_builder.lt(term_val),
|
||||
&Unbounded => term_stream_builder,
|
||||
term_stream_builder = match self.right_bound {
|
||||
Included(ref term_val) => term_stream_builder.le(term_val),
|
||||
Excluded(ref term_val) => term_stream_builder.lt(term_val),
|
||||
Unbounded => term_stream_builder,
|
||||
};
|
||||
term_stream_builder.into_stream()
|
||||
}
|
||||
|
||||
@@ -50,11 +50,7 @@ where
|
||||
{
|
||||
fn advance(&mut self) -> bool {
|
||||
self.score_cache = None;
|
||||
if self.req_scorer.advance() {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
self.req_scorer.advance()
|
||||
}
|
||||
|
||||
fn doc(&self) -> DocId {
|
||||
|
||||
Reference in New Issue
Block a user