@@ -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