Skip to content

Commit ef2a9f1

Browse files
committed
Implement batched_multi_get_multi_cf_opt().
Signed-off-by: Jason Volk <jason@zemos.net>
1 parent f78e3a4 commit ef2a9f1

File tree

3 files changed

+50
-7
lines changed

3 files changed

+50
-7
lines changed

.gitmodules

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
#[submodule "rocksdb_sys/snappy"]
2-
# path = librocksdb-sys/snappy
3-
# url = https://github.com/google/snappy.git
4-
# shallow = true
51
[submodule "rocksdb_sys/rocksdb"]
62
path = librocksdb-sys/rocksdb
7-
url = https://github.com/girlbossceo/rocksdb.git
8-
branch = v9.11.1
3+
url = https://github.com/matrix-construct/rocksdb.git
4+
branch = v9.10.0
95
shallow = true

librocksdb-sys/rocksdb

Submodule rocksdb updated 417 files

src/db.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,53 @@ impl<T: ThreadMode, D: DBInner> DBCommon<T, D> {
12831283
}
12841284
}
12851285

1286+
/// Return the values associated with the given keys and the specified
1287+
/// column families where internally the read requests are processed in
1288+
/// batch if block-based table SST format is used. It is a more optimized
1289+
/// version of multi_get_cf_opt, and allows for multiple column families.
1290+
pub fn batched_multi_get_multi_cf_opt<'a, C, K, I>(
1291+
&self,
1292+
keys: I,
1293+
sorted_input: bool,
1294+
readopts: &ReadOptions,
1295+
) -> impl Iterator<Item = Result<Option<DBPinnableSlice>, Error>>
1296+
where
1297+
K: AsRef<[u8]> + 'a + ?Sized,
1298+
I: IntoIterator<Item = (&'a C, &'a K)>,
1299+
C: AsColumnFamilyRef + 'a,
1300+
{
1301+
let (ptr_cfs, (ptr_keys, keys_sizes)): (Vec<_>, (Vec<_>, Vec<_>)) = keys
1302+
.into_iter()
1303+
.map(|(cf, k)| (cf.inner(), k.as_ref()))
1304+
.map(|(cf, k)| (cf, ((k.as_ptr() as *const c_char), k.len())))
1305+
.unzip();
1306+
1307+
let mut pinned_values = vec![ptr::null_mut(); ptr_keys.len()];
1308+
let mut errors = vec![ptr::null_mut(); ptr_keys.len()];
1309+
unsafe {
1310+
ffi::rocksdb_batched_multi_get_multi_cf(
1311+
self.inner.inner(),
1312+
readopts.inner,
1313+
ptr_keys.len(),
1314+
ptr_cfs.as_ptr().cast_mut(),
1315+
ptr_keys.as_ptr(),
1316+
keys_sizes.as_ptr(),
1317+
pinned_values.as_mut_ptr(),
1318+
errors.as_mut_ptr(),
1319+
sorted_input,
1320+
);
1321+
}
1322+
pinned_values
1323+
.into_iter()
1324+
.zip(errors)
1325+
.map(|(v, e)| match (v, e) {
1326+
_ if !e.is_null() => Err(Error::new(crate::ffi_util::error_message(e))),
1327+
_ if !v.is_null() => Ok(Some(unsafe { DBPinnableSlice::from_c(v) })),
1328+
_ if v.is_null() => Ok(None),
1329+
_ => unreachable!(),
1330+
})
1331+
}
1332+
12861333
/// Returns `false` if the given key definitely doesn't exist in the database, otherwise returns
12871334
/// `true`. This function uses default `ReadOptions`.
12881335
pub fn key_may_exist<K: AsRef<[u8]>>(&self, key: K) -> bool {

0 commit comments

Comments
 (0)