add multi_get (multi_get_cf) for rocksdb
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
238c371ef4
commit
0db3a43d1f
2 changed files with 11 additions and 0 deletions
|
@ -30,6 +30,11 @@ pub(crate) trait KeyValueDatabaseEngine: Send + Sync {
|
|||
pub(crate) trait KvTree: Send + Sync {
|
||||
fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>>;
|
||||
|
||||
#[cfg(feature = "rocksdb")]
|
||||
fn multi_get(
|
||||
&self, iter: Vec<(&Arc<rust_rocksdb::BoundColumnFamily<'_>>, Vec<u8>)>,
|
||||
) -> Vec<std::result::Result<Option<Vec<u8>>, rust_rocksdb::Error>>;
|
||||
|
||||
fn insert(&self, key: &[u8], value: &[u8]) -> Result<()>;
|
||||
fn insert_batch(&self, iter: &mut dyn Iterator<Item = (Vec<u8>, Vec<u8>)>) -> Result<()>;
|
||||
|
||||
|
|
|
@ -184,6 +184,12 @@ impl RocksDbEngineTree<'_> {
|
|||
impl KvTree for RocksDbEngineTree<'_> {
|
||||
fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>> { Ok(self.db.rocks.get_cf(&self.cf(), key)?) }
|
||||
|
||||
fn multi_get(
|
||||
&self, iter: Vec<(&Arc<rust_rocksdb::BoundColumnFamily<'_>>, Vec<u8>)>,
|
||||
) -> Vec<std::result::Result<Option<Vec<u8>>, rust_rocksdb::Error>> {
|
||||
self.db.rocks.multi_get_cf(iter)
|
||||
}
|
||||
|
||||
fn insert(&self, key: &[u8], value: &[u8]) -> Result<()> {
|
||||
let lock = self.write_lock.read().unwrap();
|
||||
self.db.rocks.put_cf(&self.cf(), key, value)?;
|
||||
|
|
Loading…
Add table
Reference in a new issue