From 0db3a43d1f5be3fdb4358765251d50f34e32fb3b Mon Sep 17 00:00:00 2001 From: strawberry Date: Wed, 13 Mar 2024 01:54:14 -0400 Subject: [PATCH] add multi_get (multi_get_cf) for rocksdb Signed-off-by: strawberry --- src/database/abstraction.rs | 5 +++++ src/database/abstraction/rocksdb.rs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/database/abstraction.rs b/src/database/abstraction.rs index ebf4e4b9..16f7d440 100644 --- a/src/database/abstraction.rs +++ b/src/database/abstraction.rs @@ -30,6 +30,11 @@ pub(crate) trait KeyValueDatabaseEngine: Send + Sync { pub(crate) trait KvTree: Send + Sync { fn get(&self, key: &[u8]) -> Result>>; + #[cfg(feature = "rocksdb")] + fn multi_get( + &self, iter: Vec<(&Arc>, Vec)>, + ) -> Vec>, rust_rocksdb::Error>>; + fn insert(&self, key: &[u8], value: &[u8]) -> Result<()>; fn insert_batch(&self, iter: &mut dyn Iterator, Vec)>) -> Result<()>; diff --git a/src/database/abstraction/rocksdb.rs b/src/database/abstraction/rocksdb.rs index ddd448fd..4194e8b1 100644 --- a/src/database/abstraction/rocksdb.rs +++ b/src/database/abstraction/rocksdb.rs @@ -184,6 +184,12 @@ impl RocksDbEngineTree<'_> { impl KvTree for RocksDbEngineTree<'_> { fn get(&self, key: &[u8]) -> Result>> { Ok(self.db.rocks.get_cf(&self.cf(), key)?) } + fn multi_get( + &self, iter: Vec<(&Arc>, Vec)>, + ) -> Vec>, 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)?;