Merge pull request #174 from meilisearch/arc-fst-sets

Do not clone probably large fst::Sets, Arc them
This commit is contained in:
Clément Renault 2019-08-30 14:52:28 +02:00 committed by GitHub
commit a420fbf1e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 10 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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()? {

View File

@ -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();

View File

@ -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();