From 93a8633f188150e2d13c7a2d5a3d6773f0c9d204 Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Wed, 9 Jun 2021 14:45:56 +0200 Subject: [PATCH] Remove the documents_merge method that must never be called --- milli/src/update/index_documents/merge_function.rs | 4 ---- milli/src/update/index_documents/mod.rs | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/milli/src/update/index_documents/merge_function.rs b/milli/src/update/index_documents/merge_function.rs index c8424dc8c..904368fb0 100644 --- a/milli/src/update/index_documents/merge_function.rs +++ b/milli/src/update/index_documents/merge_function.rs @@ -26,10 +26,6 @@ pub fn keep_first(_key: &[u8], values: &[Cow<[u8]>]) -> anyhow::Result> Ok(values.first().unwrap().to_vec()) } -pub fn documents_merge(key: &[u8], _values: &[Cow<[u8]>]) -> anyhow::Result> { - bail!("merging documents is an error ({:?})", key.as_bstr()) -} - pub fn merge_two_obkvs(base: obkv::KvReader, update: obkv::KvReader, buffer: &mut Vec) { use itertools::merge_join_by; use itertools::EitherOrBoth::{Both, Left, Right}; diff --git a/milli/src/update/index_documents/mod.rs b/milli/src/update/index_documents/mod.rs index 2b790ce06..7fb47fa4a 100644 --- a/milli/src/update/index_documents/mod.rs +++ b/milli/src/update/index_documents/mod.rs @@ -26,7 +26,7 @@ use crate::update::{ use self::store::{Store, Readers}; pub use self::merge_function::{ fst_merge, cbo_roaring_bitmap_merge, roaring_bitmap_merge, - docid_word_positions_merge, documents_merge, keep_first + docid_word_positions_merge, keep_first }; pub use self::transform::{Transform, TransformOutput}; @@ -149,7 +149,7 @@ pub fn write_into_lmdb_database( let mut iter = database.prefix_iter_mut::<_, ByteSlice, ByteSlice>(wtxn, k)?; match iter.next().transpose()? { Some((key, old_val)) if key == k => { - let vals = vec![Cow::Borrowed(old_val), Cow::Borrowed(v)]; + let vals = &[Cow::Borrowed(old_val), Cow::Borrowed(v)][..]; let val = merge(k, &vals)?; iter.put_current(k, &val)?; }, @@ -634,12 +634,12 @@ impl<'t, 'u, 'i, 'a> IndexDocuments<'t, 'u, 'i, 'a> { total_databases, }); - debug!("Writing the documents into LMDB on disk..."); + debug!("Inserting the documents into LMDB on disk..."); merge_into_lmdb_database( self.wtxn, *self.index.documents.as_polymorph(), documents_readers, - documents_merge, + keep_first, write_method )?;