mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 02:27:40 +08:00
Apply code suggestions
Co-authored-by: Clément Renault <clement@meilisearch.com>
This commit is contained in:
parent
399fba16bb
commit
00f78d6b5a
@ -3,9 +3,9 @@ use serde_json::Value;
|
|||||||
/// Your json MUST BE valid and generated by `serde_json::to_vec` before being
|
/// Your json MUST BE valid and generated by `serde_json::to_vec` before being
|
||||||
/// sent in this function. This function is DUMB and FAST but makes a lot of
|
/// sent in this function. This function is DUMB and FAST but makes a lot of
|
||||||
/// asumption about the way `serde_json` will generate its input.
|
/// asumption about the way `serde_json` will generate its input.
|
||||||
/// Will returns `true` if the json contains an object, an array of array
|
///
|
||||||
/// or an array containing an object.
|
/// Will return `true` if the JSON contains an object, an array of array
|
||||||
/// Returns `false` for everything else.
|
/// or an array containing an object. Returns `false` for everything else.
|
||||||
pub fn should_flatten_from_unchecked_slice(json: &[u8]) -> bool {
|
pub fn should_flatten_from_unchecked_slice(json: &[u8]) -> bool {
|
||||||
if json.is_empty() {
|
if json.is_empty() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -286,10 +286,9 @@ impl<'a, 'i> Transform<'a, 'i> {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
self.original_sorter.insert(&docid.to_be_bytes(), base_obkv)?;
|
self.original_sorter.insert(&docid.to_be_bytes(), base_obkv)?;
|
||||||
if let Some(buffer) = self.flatten_from_fields_ids_map(KvReader::new(&base_obkv))? {
|
match self.flatten_from_fields_ids_map(KvReader::new(&base_obkv))? {
|
||||||
self.flattened_sorter.insert(docid.to_be_bytes(), &buffer)?;
|
Some(buffer) => self.flattened_sorter.insert(docid.to_be_bytes(), &buffer)?,
|
||||||
} else {
|
None => self.flattened_sorter.insert(docid.to_be_bytes(), base_obkv)?,
|
||||||
self.flattened_sorter.insert(docid.to_be_bytes(), base_obkv)?;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.new_documents_ids.insert(docid);
|
self.new_documents_ids.insert(docid);
|
||||||
@ -302,12 +301,11 @@ impl<'a, 'i> Transform<'a, 'i> {
|
|||||||
if let Some(flatten) = flattened_document {
|
if let Some(flatten) = flattened_document {
|
||||||
self.flattened_sorter.insert(docid.to_be_bytes(), &flatten)?;
|
self.flattened_sorter.insert(docid.to_be_bytes(), &flatten)?;
|
||||||
} else {
|
} else {
|
||||||
if let Some(buffer) =
|
match self.flatten_from_fields_ids_map(KvReader::new(&obkv_buffer))? {
|
||||||
self.flatten_from_fields_ids_map(KvReader::new(&obkv_buffer))?
|
Some(buffer) => self.flattened_sorter.insert(docid.to_be_bytes(), &buffer)?,
|
||||||
{
|
None => {
|
||||||
self.flattened_sorter.insert(docid.to_be_bytes(), &buffer)?;
|
self.flattened_sorter.insert(docid.to_be_bytes(), obkv_buffer.clone())?
|
||||||
} else {
|
}
|
||||||
self.flattened_sorter.insert(docid.to_be_bytes(), obkv_buffer.clone())?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user