@@ -1462,6 +1462,53 @@ impl<T: ThreadMode, D: DBInner> DBCommon<T, D> {
14621462 }
14631463 }
14641464
1465+ /// Return the values associated with the given keys and the specified
1466+ /// column families where internally the read requests are processed in
1467+ /// batch if block-based table SST format is used. It is a more optimized
1468+ /// version of multi_get_cf_opt, and allows for multiple column families.
1469+ pub fn batched_multi_get_multi_cf_opt < ' a , C , K , I > (
1470+ & self ,
1471+ keys : I ,
1472+ sorted_input : bool ,
1473+ readopts : & ReadOptions ,
1474+ ) -> impl Iterator < Item = Result < Option < DBPinnableSlice < ' _ > > , Error > >
1475+ where
1476+ K : AsRef < [ u8 ] > + ' a + ?Sized ,
1477+ I : IntoIterator < Item = ( & ' a C , & ' a K ) > ,
1478+ C : AsColumnFamilyRef + ' a ,
1479+ {
1480+ let ( ptr_cfs, ( ptr_keys, keys_sizes) ) : ( Vec < _ > , ( Vec < _ > , Vec < _ > ) ) = keys
1481+ . into_iter ( )
1482+ . map ( |( cf, k) | ( cf. inner ( ) , k. as_ref ( ) ) )
1483+ . map ( |( cf, k) | ( cf, ( ( k. as_ptr ( ) as * const c_char ) , k. len ( ) ) ) )
1484+ . unzip ( ) ;
1485+
1486+ let mut pinned_values = vec ! [ ptr:: null_mut( ) ; ptr_keys. len( ) ] ;
1487+ let mut errors = vec ! [ ptr:: null_mut( ) ; ptr_keys. len( ) ] ;
1488+ unsafe {
1489+ ffi:: rocksdb_batched_multi_get_multi_cf (
1490+ self . inner . inner ( ) ,
1491+ readopts. inner ,
1492+ ptr_keys. len ( ) ,
1493+ ptr_cfs. as_ptr ( ) . cast_mut ( ) ,
1494+ ptr_keys. as_ptr ( ) ,
1495+ keys_sizes. as_ptr ( ) ,
1496+ pinned_values. as_mut_ptr ( ) ,
1497+ errors. as_mut_ptr ( ) ,
1498+ sorted_input,
1499+ ) ;
1500+ }
1501+ pinned_values
1502+ . into_iter ( )
1503+ . zip ( errors)
1504+ . map ( |( v, e) | match ( v, e) {
1505+ _ if !e. is_null ( ) => Err ( Error :: new ( crate :: ffi_util:: error_message ( e) ) ) ,
1506+ _ if !v. is_null ( ) => Ok ( Some ( unsafe { DBPinnableSlice :: from_c ( v) } ) ) ,
1507+ _ if v. is_null ( ) => Ok ( None ) ,
1508+ _ => unreachable ! ( ) ,
1509+ } )
1510+ }
1511+
14651512 /// Returns `false` if the given key definitely doesn't exist in the database, otherwise returns
14661513 /// `true`. This function uses default `ReadOptions`.
14671514 pub fn key_may_exist < K : AsRef < [ u8 ] > > ( & self , key : K ) -> bool {
0 commit comments