mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 05:14:27 +01:00
feat: Do not clone probably large fst::Sets, Arc them
This commit is contained in:
parent
3e1b81c4ce
commit
ca34c28335
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -30,8 +30,8 @@ pub struct IndexStats {
|
||||
pub struct Index(pub ArcSwap<InnerIndex>);
|
||||
|
||||
pub struct InnerIndex {
|
||||
pub words: fst::Set,
|
||||
pub synonyms: fst::Set,
|
||||
pub words: Arc<fst::Set>,
|
||||
pub synonyms: Arc<fst::Set>,
|
||||
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<Index, Error> {
|
||||
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()? {
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user