Introduce synonyms deletions updates

This commit is contained in:
Clément Renault 2019-10-08 17:16:48 +02:00
parent 0e224efa46
commit ba32ce21d0
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
4 changed files with 199 additions and 1 deletions

View file

@ -1,4 +1,5 @@
use std::sync::Arc;
use rkv::StoreError;
use crate::error::MResult;
#[derive(Copy, Clone)]
@ -18,6 +19,19 @@ impl Synonyms {
self.synonyms.put(writer, word, &blob)
}
pub fn del_synonyms(
&self,
writer: &mut rkv::Writer,
word: &[u8],
) -> Result<bool, rkv::StoreError>
{
match self.synonyms.delete(writer, word) {
Ok(()) => Ok(true),
Err(StoreError::LmdbError(lmdb::Error::NotFound)) => Ok(false),
Err(e) => Err(e),
}
}
pub fn synonyms(
&self,
reader: &impl rkv::Readable,