From bcd38c7d5a35524edd2187f8d0d15c644405fc8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Mon, 16 Sep 2019 12:33:08 +0200 Subject: [PATCH] feat: Unify the Update and UpdateOwned types --- meilidb-data/src/database/index/mod.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/meilidb-data/src/database/index/mod.rs b/meilidb-data/src/database/index/mod.rs index e3f205624..34c71db05 100644 --- a/meilidb-data/src/database/index/mod.rs +++ b/meilidb-data/src/database/index/mod.rs @@ -40,15 +40,7 @@ mod main_index; mod synonyms_index; mod words_index; -#[derive(Deserialize)] -enum UpdateOwned { - DocumentsAddition(Vec), - DocumentsDeletion(Vec), - SynonymsAddition(BTreeMap>), - SynonymsDeletion(BTreeMap>>), -} - -#[derive(Serialize)] +#[derive(Serialize, Deserialize)] enum Update { DocumentsAddition(Vec), DocumentsDeletion(Vec), @@ -91,27 +83,27 @@ fn spawn_update_system(index: Index, subscription: Receiver<()>) -> thread::Join let update = updates.get(&key).unwrap().unwrap(); let (update_type, result, duration) = match rmp_serde::from_read_ref(&update).unwrap() { - UpdateOwned::DocumentsAddition(documents) => { + Update::DocumentsAddition(documents) => { let update_type = UpdateType::DocumentsAddition { number: documents.len() }; let ranked_map = index.cache.load().ranked_map.clone(); let start = Instant::now(); let result = apply_documents_addition(&index, ranked_map, documents); (update_type, result, start.elapsed()) }, - UpdateOwned::DocumentsDeletion(documents) => { + Update::DocumentsDeletion(documents) => { let update_type = UpdateType::DocumentsDeletion { number: documents.len() }; let ranked_map = index.cache.load().ranked_map.clone(); let start = Instant::now(); let result = apply_documents_deletion(&index, ranked_map, documents); (update_type, result, start.elapsed()) }, - UpdateOwned::SynonymsAddition(synonyms) => { + Update::SynonymsAddition(synonyms) => { let update_type = UpdateType::SynonymsAddition { number: synonyms.len() }; let start = Instant::now(); let result = apply_synonyms_addition(&index, synonyms); (update_type, result, start.elapsed()) }, - UpdateOwned::SynonymsDeletion(synonyms) => { + Update::SynonymsDeletion(synonyms) => { let update_type = UpdateType::SynonymsDeletion { number: synonyms.len() }; let start = Instant::now(); let result = apply_synonyms_deletion(&index, synonyms);