From c0f2724c2d72b8b8158a0390245e88b33f581975 Mon Sep 17 00:00:00 2001 From: Tamo Date: Tue, 10 Oct 2023 15:12:23 +0200 Subject: [PATCH] get rids of the new introduced error code in favor of an io::Error --- milli/src/error.rs | 2 -- .../update/index_documents/helpers/grenad_helpers.rs | 5 +---- milli/src/update/index_documents/transform.rs | 12 ++++-------- milli/src/update/prefix_word_pairs/mod.rs | 7 ++----- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/milli/src/error.rs b/milli/src/error.rs index 303199bcb..e9e1fddd3 100644 --- a/milli/src/error.rs +++ b/milli/src/error.rs @@ -47,8 +47,6 @@ pub enum InternalError { IndexingMergingKeys { process: &'static str }, #[error("{}", HeedError::InvalidDatabaseTyping)] InvalidDatabaseTyping, - #[error("Could not access the inner of a buf-reader/writer: {0}")] - BufIntoInnerError(String), #[error(transparent)] RayonThreadPool(#[from] ThreadPoolBuildError), #[error(transparent)] diff --git a/milli/src/update/index_documents/helpers/grenad_helpers.rs b/milli/src/update/index_documents/helpers/grenad_helpers.rs index f25fa9c53..582bf2a5b 100644 --- a/milli/src/update/index_documents/helpers/grenad_helpers.rs +++ b/milli/src/update/index_documents/helpers/grenad_helpers.rs @@ -67,10 +67,7 @@ pub fn sorter_into_reader( pub fn writer_into_reader( writer: grenad::Writer>, ) -> Result>> { - let mut file = writer - .into_inner()? - .into_inner() - .map_err(|err| InternalError::BufIntoInnerError(err.to_string()))?; + let mut file = writer.into_inner()?.into_inner().map_err(|err| err.into_error())?; file.rewind()?; grenad::Reader::new(BufReader::new(file)).map_err(Into::into) } diff --git a/milli/src/update/index_documents/transform.rs b/milli/src/update/index_documents/transform.rs index 450cc705e..f0e3bbbf0 100644 --- a/milli/src/update/index_documents/transform.rs +++ b/milli/src/update/index_documents/transform.rs @@ -659,12 +659,10 @@ impl<'a, 'i> Transform<'a, 'i> { new_documents_ids: self.new_documents_ids, replaced_documents_ids: self.replaced_documents_ids, documents_count: self.documents_count, - original_documents: original_documents - .into_inner() - .map_err(|err| InternalError::BufIntoInnerError(err.to_string()))?, + original_documents: original_documents.into_inner().map_err(|err| err.into_error())?, flattened_documents: flattened_documents .into_inner() - .map_err(|err| InternalError::BufIntoInnerError(err.to_string()))?, + .map_err(|err| err.into_error())?, }) } @@ -783,12 +781,10 @@ impl<'a, 'i> Transform<'a, 'i> { new_documents_ids: documents_ids, replaced_documents_ids: RoaringBitmap::default(), documents_count, - original_documents: original_documents - .into_inner() - .map_err(|err| InternalError::BufIntoInnerError(err.to_string()))?, + original_documents: original_documents.into_inner().map_err(|err| err.into_error())?, flattened_documents: flattened_documents .into_inner() - .map_err(|err| InternalError::BufIntoInnerError(err.to_string()))?, + .map_err(|err| err.into_error())?, }; let new_facets = output.compute_real_facets(wtxn, self.index)?; diff --git a/milli/src/update/prefix_word_pairs/mod.rs b/milli/src/update/prefix_word_pairs/mod.rs index d70cad117..e3135d546 100644 --- a/milli/src/update/prefix_word_pairs/mod.rs +++ b/milli/src/update/prefix_word_pairs/mod.rs @@ -6,7 +6,7 @@ use grenad::CompressionType; use heed::types::ByteSlice; use super::index_documents::{merge_cbo_roaring_bitmaps, CursorClonableMmap}; -use crate::{Index, InternalError, Result}; +use crate::{Index, Result}; mod prefix_word; mod word_prefix; @@ -121,10 +121,7 @@ pub fn write_into_lmdb_database_without_merging( database: heed::PolyDatabase, writer: grenad::Writer>, ) -> Result<()> { - let file = writer - .into_inner()? - .into_inner() - .map_err(|err| InternalError::BufIntoInnerError(err.to_string()))?; + let file = writer.into_inner()?.into_inner().map_err(|err| err.into_error())?; let reader = grenad::Reader::new(BufReader::new(file))?; if database.is_empty(wtxn)? { let mut out_iter = database.iter_mut::<_, ByteSlice, ByteSlice>(wtxn)?;