Tiqb feature/2018 (#583)

* rust 2018

* Added CHANGELOG comment
This commit is contained in:
Paul Masurel
2019-07-01 10:01:46 +09:00
committed by GitHub
parent 185a5b8d31
commit 462774b15c
161 changed files with 1301 additions and 1318 deletions

View File

@@ -1,13 +1,13 @@
use super::boolean_weight::BooleanWeight;
use query::Occur;
use query::Query;
use query::TermQuery;
use query::Weight;
use schema::IndexRecordOption;
use schema::Term;
use crate::query::Occur;
use crate::query::Query;
use crate::query::TermQuery;
use crate::query::Weight;
use crate::schema::IndexRecordOption;
use crate::schema::Term;
use crate::Result;
use crate::Searcher;
use std::collections::BTreeSet;
use Result;
use Searcher;
/// The boolean query combines a set of queries
///
@@ -21,7 +21,7 @@ use Searcher;
/// a `MustNot` occurence.
#[derive(Debug)]
pub struct BooleanQuery {
subqueries: Vec<(Occur, Box<Query>)>,
subqueries: Vec<(Occur, Box<dyn Query>)>,
}
impl Clone for BooleanQuery {
@@ -34,14 +34,14 @@ impl Clone for BooleanQuery {
}
}
impl From<Vec<(Occur, Box<Query>)>> for BooleanQuery {
fn from(subqueries: Vec<(Occur, Box<Query>)>) -> BooleanQuery {
impl From<Vec<(Occur, Box<dyn Query>)>> for BooleanQuery {
fn from(subqueries: Vec<(Occur, Box<dyn Query>)>) -> BooleanQuery {
BooleanQuery { subqueries }
}
}
impl Query for BooleanQuery {
fn weight(&self, searcher: &Searcher, scoring_enabled: bool) -> Result<Box<Weight>> {
fn weight(&self, searcher: &Searcher, scoring_enabled: bool) -> Result<Box<dyn Weight>> {
let sub_weights = self
.subqueries
.iter()
@@ -63,10 +63,10 @@ impl BooleanQuery {
/// Helper method to create a boolean query matching a given list of terms.
/// The resulting query is a disjunction of the terms.
pub fn new_multiterms_query(terms: Vec<Term>) -> BooleanQuery {
let occur_term_queries: Vec<(Occur, Box<Query>)> = terms
let occur_term_queries: Vec<(Occur, Box<dyn Query>)> = terms
.into_iter()
.map(|term| {
let term_query: Box<Query> =
let term_query: Box<dyn Query> =
Box::new(TermQuery::new(term, IndexRecordOption::WithFreqs));
(Occur::Should, term_query)
})
@@ -75,7 +75,7 @@ impl BooleanQuery {
}
/// Deconstructed view of the clauses making up this query.
pub fn clauses(&self) -> &[(Occur, Box<Query>)] {
pub fn clauses(&self) -> &[(Occur, Box<dyn Query>)] {
&self.subqueries[..]
}
}