Add rocksdb multi_get_bytes() method (#28244)

This commit is contained in:
steviez 2022-10-07 18:05:13 -04:00 committed by GitHub
parent 00a18a962e
commit 624f5cfcd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 0 deletions

View File

@ -1223,6 +1223,40 @@ where
result
}
pub fn multi_get_bytes(&self, keys: Vec<C::Index>) -> Vec<Result<Option<Vec<u8>>>> {
let rocks_keys: Vec<_> = keys.into_iter().map(|key| C::key(key)).collect();
{
let ref_rocks_keys: Vec<_> = rocks_keys.iter().map(|k| &k[..]).collect();
let is_perf_enabled = maybe_enable_rocksdb_perf(
self.column_options.rocks_perf_sample_interval,
&self.read_perf_status,
);
let result = self
.backend
.multi_get_cf(self.handle(), ref_rocks_keys)
.into_iter()
.map(|r| match r {
Ok(opt) => match opt {
Some(pinnable_slice) => Ok(Some(pinnable_slice.as_ref().to_vec())),
None => Ok(None),
},
Err(e) => Err(e),
})
.collect::<Vec<Result<Option<_>>>>();
if let Some(op_start_instant) = is_perf_enabled {
// use multi-get instead
report_rocksdb_read_perf(
C::NAME,
PERF_METRIC_OP_NAME_MULTI_GET,
&op_start_instant.elapsed(),
&self.column_options,
);
}
result
}
}
pub fn iter(
&self,
iterator_mode: IteratorMode<C::Index>,