mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 12:35:05 +08:00
Merge pull request #156 from meilisearch/clippy-pass
Do a little clippy pass
This commit is contained in:
commit
ec20a8cacb
@ -22,7 +22,6 @@ pub use self::{
|
|||||||
pub trait Criterion: Send + Sync {
|
pub trait Criterion: Send + Sync {
|
||||||
fn evaluate(&self, lhs: &RawDocument, rhs: &RawDocument) -> Ordering;
|
fn evaluate(&self, lhs: &RawDocument, rhs: &RawDocument) -> Ordering;
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn name(&self) -> &'static str;
|
fn name(&self) -> &'static str;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -12,7 +12,7 @@ impl<K: Hash + Eq> DistinctMap<K> {
|
|||||||
pub fn new(limit: usize) -> Self {
|
pub fn new(limit: usize) -> Self {
|
||||||
DistinctMap {
|
DistinctMap {
|
||||||
inner: HashMap::new(),
|
inner: HashMap::new(),
|
||||||
limit: limit,
|
limit,
|
||||||
len: 0,
|
len: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,7 +31,7 @@ pub struct BufferedDistinctMap<'a, K> {
|
|||||||
impl<'a, K: Hash + Eq> BufferedDistinctMap<'a, K> {
|
impl<'a, K: Hash + Eq> BufferedDistinctMap<'a, K> {
|
||||||
pub fn new(internal: &'a mut DistinctMap<K>) -> BufferedDistinctMap<'a, K> {
|
pub fn new(internal: &'a mut DistinctMap<K>) -> BufferedDistinctMap<'a, K> {
|
||||||
BufferedDistinctMap {
|
BufferedDistinctMap {
|
||||||
internal: internal,
|
internal,
|
||||||
inner: HashMap::new(),
|
inner: HashMap::new(),
|
||||||
len: 0,
|
len: 0,
|
||||||
}
|
}
|
||||||
|
@ -69,11 +69,7 @@ impl<'c, S, FI> QueryBuilder<'c, S, FI>
|
|||||||
where F: Fn(DocumentId) -> Option<K>,
|
where F: Fn(DocumentId) -> Option<K>,
|
||||||
K: Hash + Eq,
|
K: Hash + Eq,
|
||||||
{
|
{
|
||||||
DistinctQueryBuilder {
|
DistinctQueryBuilder { inner: self, function, size }
|
||||||
inner: self,
|
|
||||||
function: function,
|
|
||||||
size: size
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_searchable_attribute(&mut self, attribute: u16) {
|
pub fn add_searchable_attribute(&mut self, attribute: u16) {
|
||||||
@ -116,10 +112,10 @@ where S: Store,
|
|||||||
if self.searchable_attrs.as_ref().map_or(true, |r| r.contains(&di.attribute)) {
|
if self.searchable_attrs.as_ref().map_or(true, |r| r.contains(&di.attribute)) {
|
||||||
let match_ = Match {
|
let match_ = Match {
|
||||||
query_index: iv.index as u32,
|
query_index: iv.index as u32,
|
||||||
distance: distance,
|
distance,
|
||||||
attribute: di.attribute,
|
attribute: di.attribute,
|
||||||
word_index: di.word_index,
|
word_index: di.word_index,
|
||||||
is_exact: is_exact,
|
is_exact,
|
||||||
char_index: di.char_index,
|
char_index: di.char_index,
|
||||||
char_length: di.char_length,
|
char_length: di.char_length,
|
||||||
};
|
};
|
||||||
|
@ -95,7 +95,7 @@ impl Index {
|
|||||||
let fields = fields
|
let fields = fields
|
||||||
.map(|fields| {
|
.map(|fields| {
|
||||||
fields
|
fields
|
||||||
.into_iter()
|
.iter()
|
||||||
.filter_map(|name| schema.attribute(name))
|
.filter_map(|name| schema.attribute(name))
|
||||||
.collect()
|
.collect()
|
||||||
});
|
});
|
||||||
|
@ -134,9 +134,9 @@ fn token_to_docindex(id: DocumentId, attr: SchemaAttr, token: Token) -> Option<D
|
|||||||
let docindex = DocIndex {
|
let docindex = DocIndex {
|
||||||
document_id: id,
|
document_id: id,
|
||||||
attribute: attr.0,
|
attribute: attr.0,
|
||||||
word_index: word_index,
|
word_index,
|
||||||
char_index: char_index,
|
char_index,
|
||||||
char_length: char_length,
|
char_length,
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(docindex)
|
Some(docindex)
|
||||||
|
@ -61,7 +61,7 @@ impl ser::Serializer for ConvertToNumber {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_f32(self, value: f32) -> Result<Self::Ok, Self::Error> {
|
fn serialize_f32(self, value: f32) -> Result<Self::Ok, Self::Error> {
|
||||||
Ok(Number::Float(OrderedFloat(value as f64)))
|
Ok(Number::Float(OrderedFloat(f64::from(value))))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_f64(self, value: f64) -> Result<Self::Ok, Self::Error> {
|
fn serialize_f64(self, value: f64) -> Result<Self::Ok, Self::Error> {
|
||||||
|
@ -266,26 +266,22 @@ fn serialize_value<T: ?Sized>(
|
|||||||
) -> Result<(), SerializerError>
|
) -> Result<(), SerializerError>
|
||||||
where T: ser::Serialize,
|
where T: ser::Serialize,
|
||||||
{
|
{
|
||||||
if let Some(attr) = schema.attribute(key) {
|
if let Some(attribute) = schema.attribute(key) {
|
||||||
let props = schema.props(attr);
|
let props = schema.props(attribute);
|
||||||
|
|
||||||
if props.is_stored() {
|
if props.is_stored() {
|
||||||
let value = rmp_serde::to_vec_named(value)?;
|
let value = rmp_serde::to_vec_named(value)?;
|
||||||
document_store.set_document_field(document_id, attr, value);
|
document_store.set_document_field(document_id, attribute, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if props.is_indexed() {
|
if props.is_indexed() {
|
||||||
let indexer = Indexer {
|
let indexer = Indexer { attribute, indexer, document_id };
|
||||||
attribute: attr,
|
|
||||||
indexer: indexer,
|
|
||||||
document_id: document_id,
|
|
||||||
};
|
|
||||||
value.serialize(indexer)?;
|
value.serialize(indexer)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if props.is_ranked() {
|
if props.is_ranked() {
|
||||||
let number = value.serialize(ConvertToNumber)?;
|
let number = value.serialize(ConvertToNumber)?;
|
||||||
ranked_map.insert(document_id, attr, number);
|
ranked_map.insert(document_id, attribute, number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user