From 58836d89aaa4a8f902ddf78d80776430652d6eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Mon, 30 Dec 2019 11:44:42 +0100 Subject: [PATCH] Rename the PrefixCache into PrefixDocumentsCache --- meilisearch-core/src/bucket_sort.rs | 8 +++--- meilisearch-core/src/query_builder.rs | 6 ++-- meilisearch-core/src/store/mod.rs | 28 +++++++++---------- ...fix_cache.rs => prefix_documents_cache.rs} | 12 ++++---- .../src/update/documents_addition.rs | 14 +++++----- meilisearch-core/src/update/mod.rs | 12 ++++---- meilisearch-core/src/update/schema_update.rs | 4 +-- .../src/update/stop_words_deletion.rs | 4 +-- 8 files changed, 44 insertions(+), 44 deletions(-) rename meilisearch-core/src/store/{prefix_cache.rs => prefix_documents_cache.rs} (84%) diff --git a/meilisearch-core/src/bucket_sort.rs b/meilisearch-core/src/bucket_sort.rs index 9c3a5fb53..3d3f11587 100644 --- a/meilisearch-core/src/bucket_sort.rs +++ b/meilisearch-core/src/bucket_sort.rs @@ -39,7 +39,7 @@ pub fn bucket_sort<'c, FI>( postings_lists_store: store::PostingsLists, documents_fields_counts_store: store::DocumentsFieldsCounts, synonyms_store: store::Synonyms, - prefix_cache_store: store::PrefixCache, + prefix_documents_cache_store: store::PrefixDocumentsCache, ) -> MResult> where FI: Fn(DocumentId) -> bool, @@ -62,7 +62,7 @@ where postings_lists_store, documents_fields_counts_store, synonyms_store, - prefix_cache_store, + prefix_documents_cache_store, ); } @@ -78,7 +78,7 @@ where prefix[..len].copy_from_slice(&automaton.query.as_bytes()[..len]); let mut documents = Vec::new(); - let iter = prefix_cache_store.prefix_documents(reader, prefix)?; + let iter = prefix_documents_cache_store.prefix_documents(reader, prefix)?; for result in iter.skip(range.start).take(range.len()) { let (docid, highlights) = result?; documents.push(Document::from_highlights(docid, &highlights)); @@ -201,7 +201,7 @@ pub fn bucket_sort_with_distinct<'c, FI, FD>( postings_lists_store: store::PostingsLists, documents_fields_counts_store: store::DocumentsFieldsCounts, synonyms_store: store::Synonyms, - prefix_cache_store: store::PrefixCache, + prefix_documents_cache_store: store::PrefixDocumentsCache, ) -> MResult> where FI: Fn(DocumentId) -> bool, diff --git a/meilisearch-core/src/query_builder.rs b/meilisearch-core/src/query_builder.rs index 56aa038b7..9babe55c7 100644 --- a/meilisearch-core/src/query_builder.rs +++ b/meilisearch-core/src/query_builder.rs @@ -16,7 +16,7 @@ pub struct QueryBuilder<'c, 'f, 'd> { postings_lists_store: store::PostingsLists, documents_fields_counts_store: store::DocumentsFieldsCounts, synonyms_store: store::Synonyms, - prefix_cache_store: store::PrefixCache, + prefix_cache_store: store::PrefixDocumentsCache, } impl<'c, 'f, 'd> QueryBuilder<'c, 'f, 'd> { @@ -25,7 +25,7 @@ impl<'c, 'f, 'd> QueryBuilder<'c, 'f, 'd> { postings_lists: store::PostingsLists, documents_fields_counts: store::DocumentsFieldsCounts, synonyms: store::Synonyms, - prefix_cache: store::PrefixCache, + prefix_cache: store::PrefixDocumentsCache, ) -> QueryBuilder<'c, 'f, 'd> { QueryBuilder::with_criteria( main, @@ -42,7 +42,7 @@ impl<'c, 'f, 'd> QueryBuilder<'c, 'f, 'd> { postings_lists: store::PostingsLists, documents_fields_counts: store::DocumentsFieldsCounts, synonyms: store::Synonyms, - prefix_cache: store::PrefixCache, + prefix_cache: store::PrefixDocumentsCache, criteria: Criteria<'c>, ) -> QueryBuilder<'c, 'f, 'd> { QueryBuilder { diff --git a/meilisearch-core/src/store/mod.rs b/meilisearch-core/src/store/mod.rs index 072d92004..c76094e83 100644 --- a/meilisearch-core/src/store/mod.rs +++ b/meilisearch-core/src/store/mod.rs @@ -1,5 +1,5 @@ mod docs_words; -mod prefix_cache; +mod prefix_documents_cache; mod documents_fields; mod documents_fields_counts; mod main; @@ -9,7 +9,7 @@ mod updates; mod updates_results; pub use self::docs_words::DocsWords; -pub use self::prefix_cache::PrefixCache; +pub use self::prefix_documents_cache::PrefixDocumentsCache; pub use self::documents_fields::{DocumentFieldsIter, DocumentsFields}; pub use self::documents_fields_counts::{ DocumentFieldsCountsIter, DocumentsFieldsCounts, DocumentsIdsIter, @@ -76,7 +76,7 @@ fn docs_words_name(name: &str) -> String { format!("store-{}-docs-words", name) } -fn prefix_cache_name(name: &str) -> String { +fn prefix_documents_cache_name(name: &str) -> String { format!("store-{}-prefix-cache", name) } @@ -96,7 +96,7 @@ pub struct Index { pub documents_fields_counts: DocumentsFieldsCounts, pub synonyms: Synonyms, pub docs_words: DocsWords, - pub prefix_cache: PrefixCache, + pub prefix_documents_cache: PrefixDocumentsCache, pub updates: Updates, pub updates_results: UpdatesResults, @@ -259,7 +259,7 @@ impl Index { self.postings_lists, self.documents_fields_counts, self.synonyms, - self.prefix_cache, + self.prefix_documents_cache, ) } @@ -272,7 +272,7 @@ impl Index { self.postings_lists, self.documents_fields_counts, self.synonyms, - self.prefix_cache, + self.prefix_documents_cache, criteria, ) } @@ -291,7 +291,7 @@ pub fn create( let documents_fields_counts_name = documents_fields_counts_name(name); let synonyms_name = synonyms_name(name); let docs_words_name = docs_words_name(name); - let prefix_cache_name = prefix_cache_name(name); + let prefix_documents_cache_name = prefix_documents_cache_name(name); let updates_name = updates_name(name); let updates_results_name = updates_results_name(name); @@ -302,7 +302,7 @@ pub fn create( let documents_fields_counts = env.create_database(Some(&documents_fields_counts_name))?; let synonyms = env.create_database(Some(&synonyms_name))?; let docs_words = env.create_database(Some(&docs_words_name))?; - let prefix_cache = env.create_database(Some(&prefix_cache_name))?; + let prefix_documents_cache = env.create_database(Some(&prefix_documents_cache_name))?; let updates = update_env.create_database(Some(&updates_name))?; let updates_results = update_env.create_database(Some(&updates_results_name))?; @@ -315,7 +315,7 @@ pub fn create( }, synonyms: Synonyms { synonyms }, docs_words: DocsWords { docs_words }, - prefix_cache: PrefixCache { prefix_cache }, + prefix_documents_cache: PrefixDocumentsCache { prefix_documents_cache }, updates: Updates { updates }, updates_results: UpdatesResults { updates_results }, updates_notifier, @@ -335,7 +335,7 @@ pub fn open( let documents_fields_counts_name = documents_fields_counts_name(name); let synonyms_name = synonyms_name(name); let docs_words_name = docs_words_name(name); - let prefix_cache_name = prefix_cache_name(name); + let prefix_documents_cache_name = prefix_documents_cache_name(name); let updates_name = updates_name(name); let updates_results_name = updates_results_name(name); @@ -364,8 +364,8 @@ pub fn open( Some(docs_words) => docs_words, None => return Ok(None), }; - let prefix_cache = match env.open_database(Some(&prefix_cache_name))? { - Some(prefix_cache) => prefix_cache, + let prefix_documents_cache = match env.open_database(Some(&prefix_documents_cache_name))? { + Some(prefix_documents_cache) => prefix_documents_cache, None => return Ok(None), }; let updates = match update_env.open_database(Some(&updates_name))? { @@ -386,7 +386,7 @@ pub fn open( }, synonyms: Synonyms { synonyms }, docs_words: DocsWords { docs_words }, - prefix_cache: PrefixCache { prefix_cache }, + prefix_documents_cache: PrefixDocumentsCache { prefix_documents_cache }, updates: Updates { updates }, updates_results: UpdatesResults { updates_results }, updates_notifier, @@ -405,7 +405,7 @@ pub fn clear( index.documents_fields_counts.clear(writer)?; index.synonyms.clear(writer)?; index.docs_words.clear(writer)?; - index.prefix_cache.clear(writer)?; + index.prefix_documents_cache.clear(writer)?; index.updates.clear(update_writer)?; index.updates_results.clear(update_writer)?; Ok(()) diff --git a/meilisearch-core/src/store/prefix_cache.rs b/meilisearch-core/src/store/prefix_documents_cache.rs similarity index 84% rename from meilisearch-core/src/store/prefix_cache.rs rename to meilisearch-core/src/store/prefix_documents_cache.rs index 5b1621ca8..7c916fec0 100644 --- a/meilisearch-core/src/store/prefix_cache.rs +++ b/meilisearch-core/src/store/prefix_documents_cache.rs @@ -27,11 +27,11 @@ impl PrefixKey { } #[derive(Copy, Clone)] -pub struct PrefixCache { - pub(crate) prefix_cache: heed::Database, CowSlice>, +pub struct PrefixDocumentsCache { + pub(crate) prefix_documents_cache: heed::Database, CowSlice>, } -impl PrefixCache { +impl PrefixDocumentsCache { pub fn put_prefix_document( self, writer: &mut heed::RwTxn, @@ -41,11 +41,11 @@ impl PrefixCache { highlights: &[Highlight], ) -> ZResult<()> { let key = PrefixKey::new(prefix, index as u64, docid.0); - self.prefix_cache.put(writer, &key, highlights) + self.prefix_documents_cache.put(writer, &key, highlights) } pub fn clear(self, writer: &mut heed::RwTxn) -> ZResult<()> { - self.prefix_cache.clear(writer) + self.prefix_documents_cache.clear(writer) } pub fn prefix_documents<'txn>( @@ -55,7 +55,7 @@ impl PrefixCache { ) -> ZResult> { let start = PrefixKey::new(prefix, 0, 0); let end = PrefixKey::new(prefix, u64::max_value(), u64::max_value()); - let iter = self.prefix_cache.range(reader, &(start..=end))?; + let iter = self.prefix_documents_cache.range(reader, &(start..=end))?; Ok(PrefixDocumentsIter { iter }) } } diff --git a/meilisearch-core/src/update/documents_addition.rs b/meilisearch-core/src/update/documents_addition.rs index eadb56392..d6f3ac00a 100644 --- a/meilisearch-core/src/update/documents_addition.rs +++ b/meilisearch-core/src/update/documents_addition.rs @@ -109,7 +109,7 @@ pub fn apply_documents_addition<'a, 'b>( documents_fields_counts_store: store::DocumentsFieldsCounts, postings_lists_store: store::PostingsLists, docs_words_store: store::DocsWords, - prefix_cache_store: store::PrefixCache, + prefix_documents_cache_store: store::PrefixDocumentsCache, addition: Vec>, ) -> MResult<()> { let mut documents_additions = HashMap::new(); @@ -176,7 +176,7 @@ pub fn apply_documents_addition<'a, 'b>( main_store, postings_lists_store, docs_words_store, - prefix_cache_store, + prefix_documents_cache_store, &ranked_map, number_of_inserted_documents, indexer, @@ -190,7 +190,7 @@ pub fn apply_documents_partial_addition<'a, 'b>( documents_fields_counts_store: store::DocumentsFieldsCounts, postings_lists_store: store::PostingsLists, docs_words_store: store::DocsWords, - prefix_cache_store: store::PrefixCache, + prefix_documents_cache_store: store::PrefixDocumentsCache, addition: Vec>, ) -> MResult<()> { let mut documents_additions = HashMap::new(); @@ -274,7 +274,7 @@ pub fn apply_documents_partial_addition<'a, 'b>( main_store, postings_lists_store, docs_words_store, - prefix_cache_store, + prefix_documents_cache_store, &ranked_map, number_of_inserted_documents, indexer, @@ -288,7 +288,7 @@ pub fn reindex_all_documents( documents_fields_counts_store: store::DocumentsFieldsCounts, postings_lists_store: store::PostingsLists, docs_words_store: store::DocsWords, - prefix_cache_store: store::PrefixCache, + prefix_documents_cache_store: store::PrefixDocumentsCache, ) -> MResult<()> { let schema = match main_store.schema(writer)? { Some(schema) => schema, @@ -350,7 +350,7 @@ pub fn reindex_all_documents( main_store, postings_lists_store, docs_words_store, - prefix_cache_store, + prefix_documents_cache_store, &ranked_map, number_of_inserted_documents, indexer, @@ -365,7 +365,7 @@ pub fn write_documents_addition_index( main_store: store::Main, postings_lists_store: store::PostingsLists, docs_words_store: store::DocsWords, - prefix_cache_store: store::PrefixCache, + prefix_documents_cache_store: store::PrefixDocumentsCache, ranked_map: &RankedMap, number_of_inserted_documents: usize, indexer: RawIndexer, diff --git a/meilisearch-core/src/update/mod.rs b/meilisearch-core/src/update/mod.rs index 6136282cf..1c18ef5d8 100644 --- a/meilisearch-core/src/update/mod.rs +++ b/meilisearch-core/src/update/mod.rs @@ -281,7 +281,7 @@ pub fn update_task<'a, 'b>( index.documents_fields_counts, index.postings_lists, index.docs_words, - index.prefix_cache, + index.prefix_documents_cache, ); (update_type, result, start.elapsed()) @@ -308,7 +308,7 @@ pub fn update_task<'a, 'b>( index.documents_fields_counts, index.postings_lists, index.docs_words, - index.prefix_cache, + index.prefix_documents_cache, documents, ); @@ -339,7 +339,7 @@ pub fn update_task<'a, 'b>( index.postings_lists, index.documents_fields_counts, index.synonyms, - index.prefix_cache, + index.prefix_documents_cache, ).unwrap(); let mut prefix = [0; 4]; @@ -347,7 +347,7 @@ pub fn update_task<'a, 'b>( prefix[..len].copy_from_slice(&s.as_bytes()[..len]); for (i, document) in documents.into_iter().enumerate() { - index.prefix_cache.put_prefix_document( + index.prefix_documents_cache.put_prefix_document( writer, prefix, i, @@ -381,7 +381,7 @@ pub fn update_task<'a, 'b>( index.documents_fields_counts, index.postings_lists, index.docs_words, - index.prefix_cache, + index.prefix_documents_cache, documents, ); @@ -443,7 +443,7 @@ pub fn update_task<'a, 'b>( index.documents_fields_counts, index.postings_lists, index.docs_words, - index.prefix_cache, + index.prefix_documents_cache, stop_words, ); diff --git a/meilisearch-core/src/update/schema_update.rs b/meilisearch-core/src/update/schema_update.rs index 9c1633b62..bde93346d 100644 --- a/meilisearch-core/src/update/schema_update.rs +++ b/meilisearch-core/src/update/schema_update.rs @@ -13,7 +13,7 @@ pub fn apply_schema_update( documents_fields_counts_store: store::DocumentsFieldsCounts, postings_lists_store: store::PostingsLists, docs_words_store: store::DocsWords, - prefix_cache_store: store::PrefixCache, + prefix_documents_cache_store: store::PrefixDocumentsCache, ) -> MResult<()> { use UnsupportedOperation::{ CanOnlyIntroduceNewSchemaAttributesAtEnd, CannotRemoveSchemaAttribute, @@ -56,7 +56,7 @@ pub fn apply_schema_update( documents_fields_counts_store, postings_lists_store, docs_words_store, - prefix_cache_store, + prefix_documents_cache_store, )? } diff --git a/meilisearch-core/src/update/stop_words_deletion.rs b/meilisearch-core/src/update/stop_words_deletion.rs index f0ff58a2f..7a92d0392 100644 --- a/meilisearch-core/src/update/stop_words_deletion.rs +++ b/meilisearch-core/src/update/stop_words_deletion.rs @@ -68,7 +68,7 @@ pub fn apply_stop_words_deletion( documents_fields_counts_store: store::DocumentsFieldsCounts, postings_lists_store: store::PostingsLists, docs_words_store: store::DocsWords, - prefix_cache_store: store::PrefixCache, + prefix_documents_cache_store: store::PrefixDocumentsCache, deletion: BTreeSet, ) -> MResult<()> { let mut stop_words_builder = SetBuilder::memory(); @@ -111,7 +111,7 @@ pub fn apply_stop_words_deletion( documents_fields_counts_store, postings_lists_store, docs_words_store, - prefix_cache_store, + prefix_documents_cache_store, )?; } }