fix multi_get for abstraction and limit to specific column for least-surprise

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-04-10 11:51:37 -07:00 committed by June
parent c4ebc2f1d1
commit b4080de749
2 changed files with 26 additions and 10 deletions

View file

@ -1,4 +1,4 @@
use std::{future::Future, pin::Pin, sync::Arc};
use std::{future::Future, pin::Pin};
use crate::Result;
@ -6,11 +6,13 @@ pub(crate) trait KvTree: Send + Sync {
fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>>;
#[allow(dead_code)]
#[cfg(feature = "rocksdb")]
fn multi_get(
&self, _iter: Vec<(&Arc<rust_rocksdb::BoundColumnFamily<'_>>, Vec<u8>)>,
) -> Vec<Result<Option<Vec<u8>>, rust_rocksdb::Error>> {
unimplemented!()
fn multi_get(&self, keys: &[&[u8]]) -> Result<Vec<Option<Vec<u8>>>> {
let mut ret: Vec<Option<Vec<u8>>> = Vec::with_capacity(keys.len());
for key in keys {
ret.push(self.get(key)?);
}
Ok(ret)
}
fn insert(&self, key: &[u8], value: &[u8]) -> Result<()>;