From 5f93651cefceccec3fb26d757c141493f2892674 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Mon, 18 Nov 2024 16:23:11 +0100 Subject: [PATCH] fixes --- crates/index-scheduler/src/batch.rs | 20 ++++++++-------- crates/index-scheduler/src/lib.rs | 2 ++ .../meilisearch-types/src/document_formats.rs | 5 ++-- .../new/extract/faceted/extract_facets.rs | 2 ++ .../update/new/indexer/document_operation.rs | 1 + crates/milli/src/update/new/ref_cell_ext.rs | 23 +------------------ 6 files changed, 20 insertions(+), 33 deletions(-) diff --git a/crates/index-scheduler/src/batch.rs b/crates/index-scheduler/src/batch.rs index 1ad25b422..d94c8d9a5 100644 --- a/crates/index-scheduler/src/batch.rs +++ b/crates/index-scheduler/src/batch.rs @@ -1395,15 +1395,17 @@ impl IndexScheduler { Ok(tasks) } IndexOperation::DocumentEdition { mut task, .. } => { - let (filter, context, code) = - if let KindWithContent::DocumentEdition { - filter_expr, context, function, .. - } = &task.kind - { - (filter_expr, context, function) - } else { - unreachable!() - }; + let (filter, code) = if let KindWithContent::DocumentEdition { + filter_expr, + context: _, + function, + .. + } = &task.kind + { + (filter_expr, function) + } else { + unreachable!() + }; let candidates = match filter.as_ref().map(Filter::from_json) { Some(Ok(Some(filter))) => { diff --git a/crates/index-scheduler/src/lib.rs b/crates/index-scheduler/src/lib.rs index 16ad3f194..5508eabab 100644 --- a/crates/index-scheduler/src/lib.rs +++ b/crates/index-scheduler/src/lib.rs @@ -971,6 +971,8 @@ impl IndexScheduler { let ProcessingTasks { started_at, processing, progress, .. } = self.processing_tasks.read().map_err(|_| Error::CorruptedTaskQueue)?.clone(); + let _ = progress; + let ret = tasks.into_iter(); if processing.is_empty() { Ok((ret.collect(), total)) diff --git a/crates/meilisearch-types/src/document_formats.rs b/crates/meilisearch-types/src/document_formats.rs index db893f880..311fcccf4 100644 --- a/crates/meilisearch-types/src/document_formats.rs +++ b/crates/meilisearch-types/src/document_formats.rs @@ -220,11 +220,12 @@ pub fn read_json(input: &File, output: impl io::Write) -> Result { let mut out = BufWriter::new(output); let mut deserializer = serde_json::Deserializer::from_slice(&input); - let count = match array_each(&mut deserializer, |obj: &RawValue| { + let res = array_each(&mut deserializer, |obj: &RawValue| { doc_alloc.reset(); let map = RawMap::from_raw_value(obj, &doc_alloc)?; to_writer(&mut out, &map) - }) { + }); + let count = match res { // The json data has been deserialized and does not need to be processed again. // The data has been transferred to the writer during the deserialization process. Ok(Ok(count)) => count, diff --git a/crates/milli/src/update/new/extract/faceted/extract_facets.rs b/crates/milli/src/update/new/extract/faceted/extract_facets.rs index d30a50c52..14b1b1bdd 100644 --- a/crates/milli/src/update/new/extract/faceted/extract_facets.rs +++ b/crates/milli/src/update/new/extract/faceted/extract_facets.rs @@ -156,6 +156,7 @@ impl FacetedDocidsExtractor { res } + #[allow(clippy::too_many_arguments)] fn facet_fn_with_options<'extractor, 'doc>( doc_alloc: &'doc Bump, cached_sorter: &mut BalancedCaches<'extractor>, @@ -336,6 +337,7 @@ fn truncate_str(s: &str) -> &str { } impl FacetedDocidsExtractor { + #[allow(clippy::too_many_arguments)] #[tracing::instrument(level = "trace", skip_all, target = "indexing::extract::faceted")] pub fn run_extraction< 'pl, diff --git a/crates/milli/src/update/new/indexer/document_operation.rs b/crates/milli/src/update/new/indexer/document_operation.rs index 634a7f207..604dd1786 100644 --- a/crates/milli/src/update/new/indexer/document_operation.rs +++ b/crates/milli/src/update/new/indexer/document_operation.rs @@ -106,6 +106,7 @@ impl<'pl> DocumentOperation<'pl> { } } +#[allow(clippy::too_many_arguments)] fn extract_addition_payload_changes<'r, 'pl: 'r>( indexer: &'pl Bump, index: &Index, diff --git a/crates/milli/src/update/new/ref_cell_ext.rs b/crates/milli/src/update/new/ref_cell_ext.rs index b147c00e5..c66f4af0a 100644 --- a/crates/milli/src/update/new/ref_cell_ext.rs +++ b/crates/milli/src/update/new/ref_cell_ext.rs @@ -1,37 +1,16 @@ -use std::cell::{Ref, RefCell, RefMut}; +use std::cell::{RefCell, RefMut}; pub trait RefCellExt { - fn try_borrow_or_yield(&self) -> std::result::Result, std::cell::BorrowError>; fn try_borrow_mut_or_yield( &self, ) -> std::result::Result, std::cell::BorrowMutError>; - fn borrow_or_yield(&self) -> Ref<'_, T> { - self.try_borrow_or_yield().unwrap() - } - fn borrow_mut_or_yield(&self) -> RefMut<'_, T> { self.try_borrow_mut_or_yield().unwrap() } } impl RefCellExt for RefCell { - fn try_borrow_or_yield(&self) -> std::result::Result, std::cell::BorrowError> { - /// TODO: move this trait and impl elsewhere - loop { - match self.try_borrow() { - Ok(borrow) => break Ok(borrow), - Err(error) => { - tracing::warn!("dynamic borrow failed, yielding to local tasks"); - match rayon::yield_local() { - Some(rayon::Yield::Executed) => continue, - _ => return Err(error), - } - } - } - } - } - fn try_borrow_mut_or_yield( &self, ) -> std::result::Result, std::cell::BorrowMutError> {