mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 00:31:02 +00:00
Done a big clippy pass
This commit is contained in:
@ -273,9 +273,9 @@ impl<'t, 'u, 'i, 'a> IndexDocuments<'t, 'u, 'i, 'a> {
|
||||
};
|
||||
|
||||
let output = match self.update_format {
|
||||
UpdateFormat::Csv => transform.from_csv(reader, &progress_callback)?,
|
||||
UpdateFormat::Json => transform.from_json(reader, &progress_callback)?,
|
||||
UpdateFormat::JsonStream => transform.from_json_stream(reader, &progress_callback)?,
|
||||
UpdateFormat::Csv => transform.output_from_csv(reader, &progress_callback)?,
|
||||
UpdateFormat::Json => transform.output_from_json(reader, &progress_callback)?,
|
||||
UpdateFormat::JsonStream => transform.output_from_json_stream(reader, &progress_callback)?,
|
||||
};
|
||||
|
||||
info!("Update transformed in {:.02?}", before_transform.elapsed());
|
||||
|
@ -440,7 +440,7 @@ impl Store {
|
||||
}
|
||||
|
||||
// Compute the document id of the next document.
|
||||
count = count + 1;
|
||||
count += 1;
|
||||
}
|
||||
|
||||
progress_callback(UpdateIndexingStep::IndexDocuments {
|
||||
@ -527,10 +527,8 @@ fn compute_words_pair_proximities(
|
||||
let prox = u8::try_from(prox).unwrap();
|
||||
// We don't care about a word that appear at the
|
||||
// same position or too far from the other.
|
||||
if prox >= 1 && prox <= 7 {
|
||||
if min_prox.map_or(true, |mp| prox < mp) {
|
||||
min_prox = Some(prox)
|
||||
}
|
||||
if prox >= 1 && prox <= 7 && min_prox.map_or(true, |mp| prox < mp) {
|
||||
min_prox = Some(prox)
|
||||
}
|
||||
}
|
||||
|
||||
@ -569,18 +567,28 @@ fn parse_facet_value(ftype: FacetType, value: &Value) -> anyhow::Result<SmallVec
|
||||
{
|
||||
match value {
|
||||
Value::Null => Ok(()),
|
||||
Value::Bool(b) => Ok(output.push(Integer(*b as i64))),
|
||||
Value::Bool(b) => {
|
||||
output.push(Integer(*b as i64));
|
||||
Ok(())
|
||||
},
|
||||
Value::Number(number) => match ftype {
|
||||
FacetType::String => {
|
||||
let string = SmallString32::from(number.to_string());
|
||||
Ok(output.push(String(string)))
|
||||
output.push(String(string));
|
||||
Ok(())
|
||||
},
|
||||
FacetType::Float => match number.as_f64() {
|
||||
Some(float) => Ok(output.push(Float(OrderedFloat(float)))),
|
||||
Some(float) => {
|
||||
output.push(Float(OrderedFloat(float)));
|
||||
Ok(())
|
||||
},
|
||||
None => bail!("invalid facet type, expecting {} found integer", ftype),
|
||||
},
|
||||
FacetType::Integer => match number.as_i64() {
|
||||
Some(integer) => Ok(output.push(Integer(integer))),
|
||||
Some(integer) => {
|
||||
output.push(Integer(integer));
|
||||
Ok(())
|
||||
},
|
||||
None => if number.is_f64() {
|
||||
bail!("invalid facet type, expecting {} found float", ftype)
|
||||
} else {
|
||||
@ -594,14 +602,21 @@ fn parse_facet_value(ftype: FacetType, value: &Value) -> anyhow::Result<SmallVec
|
||||
match ftype {
|
||||
FacetType::String => {
|
||||
let string = SmallString32::from(string);
|
||||
Ok(output.push(String(string)))
|
||||
output.push(String(string));
|
||||
Ok(())
|
||||
},
|
||||
FacetType::Float => match string.parse() {
|
||||
Ok(float) => Ok(output.push(Float(OrderedFloat(float)))),
|
||||
Ok(float) => {
|
||||
output.push(Float(OrderedFloat(float)));
|
||||
Ok(())
|
||||
},
|
||||
Err(_err) => bail!("invalid facet type, expecting {} found string", ftype),
|
||||
},
|
||||
FacetType::Integer => match string.parse() {
|
||||
Ok(integer) => Ok(output.push(Integer(integer))),
|
||||
Ok(integer) => {
|
||||
output.push(Integer(integer));
|
||||
Ok(())
|
||||
},
|
||||
Err(_err) => bail!("invalid facet type, expecting {} found string", ftype),
|
||||
},
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
use std::borrow::Cow;
|
||||
use std::convert::TryFrom;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Seek, SeekFrom};
|
||||
use std::iter::Peekable;
|
||||
@ -46,23 +45,23 @@ pub struct Transform<'t, 'i> {
|
||||
}
|
||||
|
||||
impl Transform<'_, '_> {
|
||||
pub fn from_json<R, F>(self, reader: R, progress_callback: F) -> anyhow::Result<TransformOutput>
|
||||
pub fn output_from_json<R, F>(self, reader: R, progress_callback: F) -> anyhow::Result<TransformOutput>
|
||||
where
|
||||
R: Read,
|
||||
F: Fn(UpdateIndexingStep) + Sync,
|
||||
{
|
||||
self.from_generic_json(reader, false, progress_callback)
|
||||
self.output_from_generic_json(reader, false, progress_callback)
|
||||
}
|
||||
|
||||
pub fn from_json_stream<R, F>(self, reader: R, progress_callback: F) -> anyhow::Result<TransformOutput>
|
||||
pub fn output_from_json_stream<R, F>(self, reader: R, progress_callback: F) -> anyhow::Result<TransformOutput>
|
||||
where
|
||||
R: Read,
|
||||
F: Fn(UpdateIndexingStep) + Sync,
|
||||
{
|
||||
self.from_generic_json(reader, true, progress_callback)
|
||||
self.output_from_generic_json(reader, true, progress_callback)
|
||||
}
|
||||
|
||||
fn from_generic_json<R, F>(
|
||||
fn output_from_generic_json<R, F>(
|
||||
self,
|
||||
reader: R,
|
||||
is_stream: bool,
|
||||
@ -221,7 +220,7 @@ impl Transform<'_, '_> {
|
||||
|
||||
// Now that we have a valid sorter that contains the user id and the obkv we
|
||||
// give it to the last transforming function which returns the TransformOutput.
|
||||
self.from_sorter(
|
||||
self.output_from_sorter(
|
||||
sorter,
|
||||
primary_key,
|
||||
fields_ids_map,
|
||||
@ -231,7 +230,7 @@ impl Transform<'_, '_> {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn from_csv<R, F>(self, reader: R, progress_callback: F) -> anyhow::Result<TransformOutput>
|
||||
pub fn output_from_csv<R, F>(self, reader: R, progress_callback: F) -> anyhow::Result<TransformOutput>
|
||||
where
|
||||
R: Read,
|
||||
F: Fn(UpdateIndexingStep) + Sync,
|
||||
@ -350,7 +349,7 @@ impl Transform<'_, '_> {
|
||||
|
||||
// Now that we have a valid sorter that contains the user id and the obkv we
|
||||
// give it to the last transforming function which returns the TransformOutput.
|
||||
self.from_sorter(
|
||||
self.output_from_sorter(
|
||||
sorter,
|
||||
primary_key_field_id,
|
||||
fields_ids_map,
|
||||
@ -363,7 +362,7 @@ impl Transform<'_, '_> {
|
||||
/// Generate the `TransformOutput` based on the given sorter that can be generated from any
|
||||
/// format like CSV, JSON or JSON stream. This sorter must contain a key that is the document
|
||||
/// id for the user side and the value must be an obkv where keys are valid fields ids.
|
||||
fn from_sorter<F>(
|
||||
fn output_from_sorter<F>(
|
||||
self,
|
||||
sorter: grenad::Sorter<MergeFn>,
|
||||
primary_key: u8,
|
||||
@ -408,7 +407,6 @@ impl Transform<'_, '_> {
|
||||
Some(docid) => {
|
||||
// If we find the user id in the current external documents ids map
|
||||
// we use it and insert it in the list of replaced documents.
|
||||
let docid = u32::try_from(docid).expect("valid document id");
|
||||
replaced_documents_ids.insert(docid);
|
||||
|
||||
// Depending on the update indexing method we will merge
|
||||
|
@ -134,3 +134,9 @@ impl<'a> UpdateBuilder<'a> {
|
||||
builder
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for UpdateBuilder<'_> {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user