introduce exact attribute setting

This commit is contained in:
ad hoc 2022-03-22 19:07:59 +01:00
parent c882d8daf0
commit f82d4b36eb
No known key found for this signature in database
GPG key ID: 4F00A782990CC643
2 changed files with 51 additions and 1 deletions

View file

@ -53,6 +53,7 @@ pub mod main_key {
pub const ONE_TYPO_WORD_LEN: &str = "one-typo-word-len";
pub const TWO_TYPOS_WORD_LEN: &str = "two-typos-word-len";
pub const EXACT_WORDS: &str = "exact-words";
pub const EXACT_ATTRIBUTES: &str = "exact-attributes";
}
pub mod db_name {
@ -949,6 +950,23 @@ impl Index {
)?;
Ok(())
}
pub fn exact_attributes<'t>(&self, txn: &'t RoTxn) -> Result<Vec<&'t str>> {
Ok(self
.main
.get::<_, Str, SerdeBincode<Vec<&str>>>(txn, main_key::EXACT_ATTRIBUTES)?
.unwrap_or_default())
}
pub(crate) fn put_exact_attributes(&self, txn: &mut RwTxn, attrs: &[&str]) -> Result<()> {
self.main.put::<_, Str, SerdeBincode<&[&str]>>(txn, main_key::EXACT_ATTRIBUTES, &attrs)?;
Ok(())
}
pub(crate) fn delete_exact_attributes(&self, txn: &mut RwTxn) -> Result<()> {
self.main.delete::<_, Str>(txn, main_key::EXACT_ATTRIBUTES)?;
Ok(())
}
}
#[cfg(test)]