Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Apply code suggestions
Browse files Browse the repository at this point in the history
Co-authored-by: Clément Renault <clement@meilisearch.com>
  • Loading branch information
irevoire and Kerollmops committed Apr 14, 2022
1 parent 399fba1 commit 00f78d6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion json-depth-checker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ criterion = "0.3"

[[bench]]
name = "depth"
harness = false
harness = false
6 changes: 3 additions & 3 deletions json-depth-checker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use serde_json::Value;
/// 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
/// 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.
/// Returns `false` for everything else.
///
/// Will return `true` if the JSON contains an object, an array of array
/// or an array containing an object. Returns `false` for everything else.
pub fn should_flatten_from_unchecked_slice(json: &[u8]) -> bool {
if json.is_empty() {
return false;
Expand Down
18 changes: 8 additions & 10 deletions milli/src/update/index_documents/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,9 @@ impl<'a, 'i> Transform<'a, 'i> {
})?;

self.original_sorter.insert(&docid.to_be_bytes(), base_obkv)?;
if let Some(buffer) = self.flatten_from_fields_ids_map(KvReader::new(&base_obkv))? {
self.flattened_sorter.insert(docid.to_be_bytes(), &buffer)?;
} else {
self.flattened_sorter.insert(docid.to_be_bytes(), base_obkv)?;
match self.flatten_from_fields_ids_map(KvReader::new(&base_obkv))? {
Some(buffer) => self.flattened_sorter.insert(docid.to_be_bytes(), &buffer)?,
None => self.flattened_sorter.insert(docid.to_be_bytes(), base_obkv)?,
}
} else {
self.new_documents_ids.insert(docid);
Expand All @@ -302,12 +301,11 @@ impl<'a, 'i> Transform<'a, 'i> {
if let Some(flatten) = flattened_document {
self.flattened_sorter.insert(docid.to_be_bytes(), &flatten)?;
} else {
if let Some(buffer) =
self.flatten_from_fields_ids_map(KvReader::new(&obkv_buffer))?
{
self.flattened_sorter.insert(docid.to_be_bytes(), &buffer)?;
} else {
self.flattened_sorter.insert(docid.to_be_bytes(), obkv_buffer.clone())?;
match 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(), obkv_buffer.clone())?
}
}
}

Expand Down

0 comments on commit 00f78d6

Please sign in to comment.