diff --git a/index-scheduler/src/autobatcher.rs b/index-scheduler/src/autobatcher.rs index b804e9caa..aedf31559 100644 --- a/index-scheduler/src/autobatcher.rs +++ b/index-scheduler/src/autobatcher.rs @@ -207,7 +207,7 @@ impl BatchKind { (BatchKind::Settings { settings_ids }, Kind::DocumentClear) => { ControlFlow::Continue(BatchKind::ClearAndSettings { - settings_ids: settings_ids.clone(), + settings_ids: settings_ids, other: vec![id], }) } diff --git a/index-scheduler/src/batch.rs b/index-scheduler/src/batch.rs index 5bc0acb2b..e20f93861 100644 --- a/index-scheduler/src/batch.rs +++ b/index-scheduler/src/batch.rs @@ -350,7 +350,7 @@ impl IndexScheduler { // matter. let index_name = task.indexes().unwrap()[0]; - let _index = self.get_index(rtxn, &index_name)? & enqueued; + let _index = self.get_index(rtxn, index_name)? & enqueued; let enqueued = enqueued .into_iter() @@ -382,7 +382,7 @@ impl IndexScheduler { | IndexOperation::DocumentClear { ref index_uid, .. } => { // only get the index, don't create it let rtxn = self.env.read_txn()?; - self.index_mapper.index(&rtxn, &index_uid)? + self.index_mapper.index(&rtxn, index_uid)? } IndexOperation::DocumentImport { ref index_uid, .. } | IndexOperation::Settings { ref index_uid, .. } @@ -390,7 +390,7 @@ impl IndexScheduler { | IndexOperation::SettingsAndDocumentImport { ref index_uid, .. } => { // create the index if it doesn't already exist let mut wtxn = self.env.write_txn()?; - let index = self.index_mapper.index(&mut wtxn, index_uid)?; + let index = self.index_mapper.create_index(&mut wtxn, index_uid)?; wtxn.commit()?; index } diff --git a/index-scheduler/src/index_mapper.rs b/index-scheduler/src/index_mapper.rs index 0849527dd..7217b581b 100644 --- a/index-scheduler/src/index_mapper.rs +++ b/index-scheduler/src/index_mapper.rs @@ -72,8 +72,8 @@ impl IndexMapper { pub fn index(&self, rtxn: &RoTxn, name: &str) -> Result { let uuid = self .index_mapping - .get(&rtxn, name)? - .ok_or(Error::IndexNotFound(name.to_string()))?; + .get(rtxn, name)? + .ok_or_else(|| Error::IndexNotFound(name.to_string()))?; // we clone here to drop the lock before entering the match let index = self.index_map.read().unwrap().get(&uuid).cloned(); @@ -109,7 +109,7 @@ impl IndexMapper { pub fn indexes(&self, rtxn: &RoTxn) -> Result> { self.index_mapping - .iter(&rtxn)? + .iter(rtxn)? .map(|ret| { ret.map_err(Error::from) .and_then(|(name, _)| self.index(rtxn, name)) @@ -122,11 +122,11 @@ impl IndexMapper { let lhs_uuid = self .index_mapping .get(wtxn, lhs)? - .ok_or(Error::IndexNotFound(lhs.to_string()))?; + .ok_or_else(|| Error::IndexNotFound(lhs.to_string()))?; let rhs_uuid = self .index_mapping .get(wtxn, rhs)? - .ok_or(Error::IndexNotFound(rhs.to_string()))?; + .ok_or_else(|| Error::IndexNotFound(rhs.to_string()))?; self.index_mapping.put(wtxn, lhs, &rhs_uuid)?; self.index_mapping.put(wtxn, rhs, &lhs_uuid)?; diff --git a/index-scheduler/src/index_scheduler.rs b/index-scheduler/src/index_scheduler.rs index 308a00fa5..49e90562d 100644 --- a/index-scheduler/src/index_scheduler.rs +++ b/index-scheduler/src/index_scheduler.rs @@ -189,10 +189,10 @@ impl IndexScheduler { processing_tasks: self.processing_tasks.clone(), file_store: self.file_store.clone(), env: self.env.clone(), - all_tasks: self.all_tasks.clone(), - status: self.status.clone(), - kind: self.kind.clone(), - index_tasks: self.index_tasks.clone(), + all_tasks: self.all_tasks, + status: self.status, + kind: self.kind, + index_tasks: self.index_tasks, index_mapper: self.index_mapper.clone(), wake_up: self.wake_up.clone(), @@ -279,7 +279,7 @@ impl IndexScheduler { .map(|task| match processing.contains(task.uid) { true => TaskView { status: Status::Processing, - started_at: Some(started_at.clone()), + started_at: Some(started_at), ..task }, false => task, @@ -309,7 +309,9 @@ impl IndexScheduler { if let Some(indexes) = task.indexes() { for index in indexes { - self.update_index(&mut wtxn, index, |bitmap| drop(bitmap.insert(task.uid)))?; + self.update_index(&mut wtxn, index, |bitmap| { + bitmap.insert(task.uid); + })?; } } diff --git a/index-scheduler/src/utils.rs b/index-scheduler/src/utils.rs index e725afb4e..98b93ebfa 100644 --- a/index-scheduler/src/utils.rs +++ b/index-scheduler/src/utils.rs @@ -73,12 +73,12 @@ impl IndexScheduler { })?; } - self.all_tasks.put(wtxn, &BEU32::new(task.uid), &task)?; + self.all_tasks.put(wtxn, &BEU32::new(task.uid), task)?; Ok(()) } pub(crate) fn get_index(&self, rtxn: &RoTxn, index: &str) -> Result { - Ok(self.index_tasks.get(&rtxn, index)?.unwrap_or_default()) + Ok(self.index_tasks.get(rtxn, index)?.unwrap_or_default()) } pub(crate) fn put_index( @@ -96,7 +96,7 @@ impl IndexScheduler { index: &str, f: impl Fn(&mut RoaringBitmap), ) -> Result<()> { - let mut tasks = self.get_index(&wtxn, index)?; + let mut tasks = self.get_index(wtxn, index)?; f(&mut tasks); self.put_index(wtxn, index, &tasks)?; @@ -104,7 +104,7 @@ impl IndexScheduler { } pub(crate) fn get_status(&self, rtxn: &RoTxn, status: Status) -> Result { - Ok(self.status.get(&rtxn, &status)?.unwrap_or_default()) + Ok(self.status.get(rtxn, &status)?.unwrap_or_default()) } pub(crate) fn put_status( @@ -122,7 +122,7 @@ impl IndexScheduler { status: Status, f: impl Fn(&mut RoaringBitmap), ) -> Result<()> { - let mut tasks = self.get_status(&wtxn, status)?; + let mut tasks = self.get_status(wtxn, status)?; f(&mut tasks); self.put_status(wtxn, status, &tasks)?; @@ -130,7 +130,7 @@ impl IndexScheduler { } pub(crate) fn get_kind(&self, rtxn: &RoTxn, kind: Kind) -> Result { - Ok(self.kind.get(&rtxn, &kind)?.unwrap_or_default()) + Ok(self.kind.get(rtxn, &kind)?.unwrap_or_default()) } pub(crate) fn put_kind( @@ -148,7 +148,7 @@ impl IndexScheduler { kind: Kind, f: impl Fn(&mut RoaringBitmap), ) -> Result<()> { - let mut tasks = self.get_kind(&wtxn, kind)?; + let mut tasks = self.get_kind(wtxn, kind)?; f(&mut tasks); self.put_kind(wtxn, kind, &tasks)?; diff --git a/index/src/index.rs b/index/src/index.rs index 8a76b130f..2a1d67e46 100644 --- a/index/src/index.rs +++ b/index/src/index.rs @@ -256,10 +256,10 @@ impl Index { &self, rtxn: &'a RoTxn, ) -> Result> + 'a> { - let fields_ids_map = self.fields_ids_map(&rtxn)?; + let fields_ids_map = self.fields_ids_map(rtxn)?; let all_fields: Vec<_> = fields_ids_map.iter().map(|(id, _)| id).collect(); - Ok(self.inner.all_documents(&rtxn)?.map(move |ret| { + Ok(self.inner.all_documents(rtxn)?.map(move |ret| { ret.map_err(IndexError::from) .and_then(|(_key, document)| -> Result<_> { Ok(obkv_to_json(&all_fields, &fields_ids_map, document)?) diff --git a/meilisearch-http/src/routes/indexes/documents.rs b/meilisearch-http/src/routes/indexes/documents.rs index a62fb7869..618787350 100644 --- a/meilisearch-http/src/routes/indexes/documents.rs +++ b/meilisearch-http/src/routes/indexes/documents.rs @@ -239,13 +239,12 @@ async fn document_addition( return Err(MeilisearchHttpError::InvalidContentType( format!("{}/{}", type_, subtype), ACCEPTED_CONTENT_TYPE.clone(), - ) - .into()) + )) } None => { - return Err( - MeilisearchHttpError::MissingContentType(ACCEPTED_CONTENT_TYPE.clone()).into(), - ) + return Err(MeilisearchHttpError::MissingContentType( + ACCEPTED_CONTENT_TYPE.clone(), + )) } }; @@ -277,7 +276,7 @@ async fn document_addition( Ok(Ok(documents_count)) => documents_count, Ok(Err(e)) => { index_scheduler.delete_update_file(uuid)?; - return Err(e.into()); + return Err(e); } Err(e) => { index_scheduler.delete_update_file(uuid)?;