Prefix all the store names to avoid colliding with main stores

This commit is contained in:
Clément Renault 2019-10-07 10:56:55 +02:00
parent 5139dc7f3e
commit 487411340a
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -18,28 +18,32 @@ fn aligned_to(bytes: &[u8], align: usize) -> bool {
(bytes as *const _ as *const () as usize) % align == 0 (bytes as *const _ as *const () as usize) % align == 0
} }
fn main_name(name: &str) -> String {
format!("store-{}", name)
}
fn postings_lists_name(name: &str) -> String { fn postings_lists_name(name: &str) -> String {
format!("{}-postings-lists", name) format!("store-{}-postings-lists", name)
} }
fn documents_fields_name(name: &str) -> String { fn documents_fields_name(name: &str) -> String {
format!("{}-documents-fields", name) format!("store-{}-documents-fields", name)
} }
fn synonyms_name(name: &str) -> String { fn synonyms_name(name: &str) -> String {
format!("{}-synonyms", name) format!("store-{}-synonyms", name)
} }
fn docs_words_name(name: &str) -> String { fn docs_words_name(name: &str) -> String {
format!("{}-docs-words", name) format!("store-{}-docs-words", name)
} }
fn updates_name(name: &str) -> String { fn updates_name(name: &str) -> String {
format!("{}-updates", name) format!("store-{}-updates", name)
} }
fn updates_results_name(name: &str) -> String { fn updates_results_name(name: &str) -> String {
format!("{}-updates-results", name) format!("store-{}-updates-results", name)
} }
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
@ -69,8 +73,8 @@ fn open_options(
options: rkv::StoreOptions, options: rkv::StoreOptions,
) -> Result<Index, rkv::StoreError> ) -> Result<Index, rkv::StoreError>
{ {
// create all the database names // create all the store names
let main_name = name; let main_name = main_name(name);
let postings_lists_name = postings_lists_name(name); let postings_lists_name = postings_lists_name(name);
let documents_fields_name = documents_fields_name(name); let documents_fields_name = documents_fields_name(name);
let synonyms_name = synonyms_name(name); let synonyms_name = synonyms_name(name);
@ -78,8 +82,8 @@ fn open_options(
let updates_name = updates_name(name); let updates_name = updates_name(name);
let updates_results_name = updates_results_name(name); let updates_results_name = updates_results_name(name);
// open all the database names // open all the stores
let main = env.open_single(main_name, options)?; let main = env.open_single(main_name.as_str(), options)?;
let postings_lists = env.open_single(postings_lists_name.as_str(), options)?; let postings_lists = env.open_single(postings_lists_name.as_str(), options)?;
let documents_fields = env.open_single(documents_fields_name.as_str(), options)?; let documents_fields = env.open_single(documents_fields_name.as_str(), options)?;
let synonyms = env.open_single(synonyms_name.as_str(), options)?; let synonyms = env.open_single(synonyms_name.as_str(), options)?;