diff --git a/meilidb-data/src/database/documents_addition.rs b/meilidb-data/src/database/documents_addition.rs index 15323be70..6e6c2003b 100644 --- a/meilidb-data/src/database/documents_addition.rs +++ b/meilidb-data/src/database/documents_addition.rs @@ -119,8 +119,9 @@ impl<'a> DocumentsAddition<'a> { main.set_ranked_map(&self.ranked_map)?; // update the "consistent" view of the Index + let words = Arc::new(words); let ranked_map = self.ranked_map; - let synonyms = fst::Set::from_bytes(lease_inner.synonyms.as_fst().to_vec()).unwrap(); // clone() + let synonyms = lease_inner.synonyms.clone(); let schema = lease_inner.schema.clone(); let raw = lease_inner.raw.clone(); lease_inner.raw.compact(); diff --git a/meilidb-data/src/database/documents_deletion.rs b/meilidb-data/src/database/documents_deletion.rs index 9813afe3c..d1413e353 100644 --- a/meilidb-data/src/database/documents_deletion.rs +++ b/meilidb-data/src/database/documents_deletion.rs @@ -118,8 +118,9 @@ impl<'a> DocumentsDeletion<'a> { main.set_ranked_map(&self.ranked_map)?; // update the "consistent" view of the Index + let words = Arc::new(words); let ranked_map = lease_inner.ranked_map.clone(); - let synonyms = fst::Set::from_bytes(lease_inner.synonyms.as_fst().to_vec()).unwrap(); // clone() + let synonyms = lease_inner.synonyms.clone(); let schema = lease_inner.schema.clone(); let raw = lease_inner.raw.clone(); lease_inner.raw.compact(); diff --git a/meilidb-data/src/database/index.rs b/meilidb-data/src/database/index.rs index 886d31118..edec6a89b 100644 --- a/meilidb-data/src/database/index.rs +++ b/meilidb-data/src/database/index.rs @@ -30,8 +30,8 @@ pub struct IndexStats { pub struct Index(pub ArcSwap); pub struct InnerIndex { - pub words: fst::Set, - pub synonyms: fst::Set, + pub words: Arc, + pub synonyms: Arc, pub schema: Schema, pub ranked_map: RankedMap, pub raw: RawIndex, // TODO this will be a snapshot in the future @@ -40,13 +40,13 @@ pub struct InnerIndex { impl Index { pub fn from_raw(raw: RawIndex) -> Result { let words = match raw.main.words_set()? { - Some(words) => words, - None => fst::Set::default(), + Some(words) => Arc::new(words), + None => Arc::new(fst::Set::default()), }; let synonyms = match raw.main.synonyms_set()? { - Some(synonyms) => synonyms, - None => fst::Set::default(), + Some(synonyms) => Arc::new(synonyms), + None => Arc::new(fst::Set::default()), }; let schema = match raw.main.schema()? { diff --git a/meilidb-data/src/database/synonyms_addition.rs b/meilidb-data/src/database/synonyms_addition.rs index 563cb228f..e4c364387 100644 --- a/meilidb-data/src/database/synonyms_addition.rs +++ b/meilidb-data/src/database/synonyms_addition.rs @@ -72,8 +72,9 @@ impl<'a> SynonymsAddition<'a> { main.set_synonyms_set(&synonyms)?; // update the "consistent" view of the Index - let words = main.words_set()?.unwrap_or_default(); + let words = Arc::new(main.words_set()?.unwrap_or_default()); let ranked_map = lease_inner.ranked_map.clone(); + let synonyms = Arc::new(synonyms); let schema = lease_inner.schema.clone(); let raw = lease_inner.raw.clone(); lease_inner.raw.compact(); diff --git a/meilidb-data/src/database/synonyms_deletion.rs b/meilidb-data/src/database/synonyms_deletion.rs index c07e92859..6056dba3f 100644 --- a/meilidb-data/src/database/synonyms_deletion.rs +++ b/meilidb-data/src/database/synonyms_deletion.rs @@ -115,8 +115,9 @@ impl<'a> SynonymsDeletion<'a> { main.set_synonyms_set(&synonyms)?; // update the "consistent" view of the Index - let words = main.words_set()?.unwrap_or_default(); + let words = Arc::new(main.words_set()?.unwrap_or_default()); let ranked_map = lease_inner.ranked_map.clone(); + let synonyms = Arc::new(synonyms); let schema = lease_inner.schema.clone(); let raw = lease_inner.raw.clone(); lease_inner.raw.compact();