mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
Merge pull request #174 from meilisearch/arc-fst-sets
Do not clone probably large fst::Sets, Arc them
This commit is contained in:
commit
a420fbf1e8
@ -119,8 +119,9 @@ impl<'a> DocumentsAddition<'a> {
|
|||||||
main.set_ranked_map(&self.ranked_map)?;
|
main.set_ranked_map(&self.ranked_map)?;
|
||||||
|
|
||||||
// update the "consistent" view of the Index
|
// update the "consistent" view of the Index
|
||||||
|
let words = Arc::new(words);
|
||||||
let ranked_map = self.ranked_map;
|
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 schema = lease_inner.schema.clone();
|
||||||
let raw = lease_inner.raw.clone();
|
let raw = lease_inner.raw.clone();
|
||||||
lease_inner.raw.compact();
|
lease_inner.raw.compact();
|
||||||
|
@ -118,8 +118,9 @@ impl<'a> DocumentsDeletion<'a> {
|
|||||||
main.set_ranked_map(&self.ranked_map)?;
|
main.set_ranked_map(&self.ranked_map)?;
|
||||||
|
|
||||||
// update the "consistent" view of the Index
|
// update the "consistent" view of the Index
|
||||||
|
let words = Arc::new(words);
|
||||||
let ranked_map = lease_inner.ranked_map.clone();
|
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 schema = lease_inner.schema.clone();
|
||||||
let raw = lease_inner.raw.clone();
|
let raw = lease_inner.raw.clone();
|
||||||
lease_inner.raw.compact();
|
lease_inner.raw.compact();
|
||||||
|
@ -30,8 +30,8 @@ pub struct IndexStats {
|
|||||||
pub struct Index(pub ArcSwap<InnerIndex>);
|
pub struct Index(pub ArcSwap<InnerIndex>);
|
||||||
|
|
||||||
pub struct InnerIndex {
|
pub struct InnerIndex {
|
||||||
pub words: fst::Set,
|
pub words: Arc<fst::Set>,
|
||||||
pub synonyms: fst::Set,
|
pub synonyms: Arc<fst::Set>,
|
||||||
pub schema: Schema,
|
pub schema: Schema,
|
||||||
pub ranked_map: RankedMap,
|
pub ranked_map: RankedMap,
|
||||||
pub raw: RawIndex, // TODO this will be a snapshot in the future
|
pub raw: RawIndex, // TODO this will be a snapshot in the future
|
||||||
@ -40,13 +40,13 @@ pub struct InnerIndex {
|
|||||||
impl Index {
|
impl Index {
|
||||||
pub fn from_raw(raw: RawIndex) -> Result<Index, Error> {
|
pub fn from_raw(raw: RawIndex) -> Result<Index, Error> {
|
||||||
let words = match raw.main.words_set()? {
|
let words = match raw.main.words_set()? {
|
||||||
Some(words) => words,
|
Some(words) => Arc::new(words),
|
||||||
None => fst::Set::default(),
|
None => Arc::new(fst::Set::default()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let synonyms = match raw.main.synonyms_set()? {
|
let synonyms = match raw.main.synonyms_set()? {
|
||||||
Some(synonyms) => synonyms,
|
Some(synonyms) => Arc::new(synonyms),
|
||||||
None => fst::Set::default(),
|
None => Arc::new(fst::Set::default()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let schema = match raw.main.schema()? {
|
let schema = match raw.main.schema()? {
|
||||||
|
@ -72,8 +72,9 @@ impl<'a> SynonymsAddition<'a> {
|
|||||||
main.set_synonyms_set(&synonyms)?;
|
main.set_synonyms_set(&synonyms)?;
|
||||||
|
|
||||||
// update the "consistent" view of the Index
|
// 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 ranked_map = lease_inner.ranked_map.clone();
|
||||||
|
let synonyms = Arc::new(synonyms);
|
||||||
let schema = lease_inner.schema.clone();
|
let schema = lease_inner.schema.clone();
|
||||||
let raw = lease_inner.raw.clone();
|
let raw = lease_inner.raw.clone();
|
||||||
lease_inner.raw.compact();
|
lease_inner.raw.compact();
|
||||||
|
@ -115,8 +115,9 @@ impl<'a> SynonymsDeletion<'a> {
|
|||||||
main.set_synonyms_set(&synonyms)?;
|
main.set_synonyms_set(&synonyms)?;
|
||||||
|
|
||||||
// update the "consistent" view of the Index
|
// 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 ranked_map = lease_inner.ranked_map.clone();
|
||||||
|
let synonyms = Arc::new(synonyms);
|
||||||
let schema = lease_inner.schema.clone();
|
let schema = lease_inner.schema.clone();
|
||||||
let raw = lease_inner.raw.clone();
|
let raw = lease_inner.raw.clone();
|
||||||
lease_inner.raw.compact();
|
lease_inner.raw.compact();
|
||||||
|
Loading…
Reference in New Issue
Block a user