mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
feat: Unify the Update and UpdateOwned types
This commit is contained in:
parent
aaeb25828f
commit
bcd38c7d5a
@ -40,15 +40,7 @@ mod main_index;
|
|||||||
mod synonyms_index;
|
mod synonyms_index;
|
||||||
mod words_index;
|
mod words_index;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
enum UpdateOwned {
|
|
||||||
DocumentsAddition(Vec<rmpv::Value>),
|
|
||||||
DocumentsDeletion(Vec<DocumentId>),
|
|
||||||
SynonymsAddition(BTreeMap<String, Vec<String>>),
|
|
||||||
SynonymsDeletion(BTreeMap<String, Option<Vec<String>>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
enum Update {
|
enum Update {
|
||||||
DocumentsAddition(Vec<rmpv::Value>),
|
DocumentsAddition(Vec<rmpv::Value>),
|
||||||
DocumentsDeletion(Vec<DocumentId>),
|
DocumentsDeletion(Vec<DocumentId>),
|
||||||
@ -91,27 +83,27 @@ fn spawn_update_system(index: Index, subscription: Receiver<()>) -> thread::Join
|
|||||||
let update = updates.get(&key).unwrap().unwrap();
|
let update = updates.get(&key).unwrap().unwrap();
|
||||||
|
|
||||||
let (update_type, result, duration) = match rmp_serde::from_read_ref(&update).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 update_type = UpdateType::DocumentsAddition { number: documents.len() };
|
||||||
let ranked_map = index.cache.load().ranked_map.clone();
|
let ranked_map = index.cache.load().ranked_map.clone();
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let result = apply_documents_addition(&index, ranked_map, documents);
|
let result = apply_documents_addition(&index, ranked_map, documents);
|
||||||
(update_type, result, start.elapsed())
|
(update_type, result, start.elapsed())
|
||||||
},
|
},
|
||||||
UpdateOwned::DocumentsDeletion(documents) => {
|
Update::DocumentsDeletion(documents) => {
|
||||||
let update_type = UpdateType::DocumentsDeletion { number: documents.len() };
|
let update_type = UpdateType::DocumentsDeletion { number: documents.len() };
|
||||||
let ranked_map = index.cache.load().ranked_map.clone();
|
let ranked_map = index.cache.load().ranked_map.clone();
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let result = apply_documents_deletion(&index, ranked_map, documents);
|
let result = apply_documents_deletion(&index, ranked_map, documents);
|
||||||
(update_type, result, start.elapsed())
|
(update_type, result, start.elapsed())
|
||||||
},
|
},
|
||||||
UpdateOwned::SynonymsAddition(synonyms) => {
|
Update::SynonymsAddition(synonyms) => {
|
||||||
let update_type = UpdateType::SynonymsAddition { number: synonyms.len() };
|
let update_type = UpdateType::SynonymsAddition { number: synonyms.len() };
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let result = apply_synonyms_addition(&index, synonyms);
|
let result = apply_synonyms_addition(&index, synonyms);
|
||||||
(update_type, result, start.elapsed())
|
(update_type, result, start.elapsed())
|
||||||
},
|
},
|
||||||
UpdateOwned::SynonymsDeletion(synonyms) => {
|
Update::SynonymsDeletion(synonyms) => {
|
||||||
let update_type = UpdateType::SynonymsDeletion { number: synonyms.len() };
|
let update_type = UpdateType::SynonymsDeletion { number: synonyms.len() };
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let result = apply_synonyms_deletion(&index, synonyms);
|
let result = apply_synonyms_deletion(&index, synonyms);
|
||||||
|
Loading…
Reference in New Issue
Block a user