@@ -17,7 +17,7 @@ use std::{
17
17
} ;
18
18
19
19
use rocksdb:: {
20
- BlockBasedOptions , ColumnFamily , ColumnFamilyDescriptor , Options , ReadOptions , WriteBatch , WriteOptions , DB ,
20
+ BlockBasedOptions , ColumnFamilyDescriptor , ColumnFamilyRef , Options , ReadOptions , WriteBatch , WriteOptions , DB
21
21
} ;
22
22
23
23
use kvdb:: { DBKeyValue , DBOp , DBTransaction , DBValue , KeyValueDB } ;
@@ -251,7 +251,7 @@ struct DBAndColumns {
251
251
}
252
252
253
253
impl DBAndColumns {
254
- fn cf ( & self , i : usize ) -> io:: Result < & ColumnFamily > {
254
+ fn cf ( & self , i : usize ) -> io:: Result < ColumnFamilyRef < ' _ > > {
255
255
let name = self . column_names . get ( i) . ok_or_else ( || invalid_column ( i as u32 ) ) ?;
256
256
self . db
257
257
. cf_handle ( & name)
@@ -377,6 +377,7 @@ impl Database {
377
377
Err ( _) => {
378
378
// retry and create CFs
379
379
match DB :: open_cf ( & opts, path. as_ref ( ) , & [ ] as & [ & str ] ) {
380
+ #[ allow( unused_mut) ] // warns when `multi-threaded-cf` feature is enabled on rocksdb, as `create_cf` takes an &self.
380
381
Ok ( mut db) => {
381
382
for ( i, name) in column_names. iter ( ) . enumerate ( ) {
382
383
let _ = db
@@ -436,31 +437,32 @@ impl Database {
436
437
match op {
437
438
DBOp :: Insert { col : _, key, value } => {
438
439
stats_total_bytes += key. len ( ) + value. len ( ) ;
439
- batch. put_cf ( cf, & key, & value) ;
440
+ batch. put_cf ( & cf, & key, & value) ;
440
441
} ,
441
442
DBOp :: Delete { col : _, key } => {
442
443
// We count deletes as writes.
443
444
stats_total_bytes += key. len ( ) ;
444
- batch. delete_cf ( cf, & key) ;
445
+ batch. delete_cf ( & cf, & key) ;
445
446
} ,
446
447
DBOp :: DeletePrefix { col, prefix } => {
447
448
let end_prefix = kvdb:: end_prefix ( & prefix[ ..] ) ;
448
449
let no_end = end_prefix. is_none ( ) ;
449
450
let end_range = end_prefix. unwrap_or_else ( || vec ! [ u8 :: max_value( ) ; 16 ] ) ;
450
- batch. delete_range_cf ( cf, & prefix[ ..] , & end_range[ ..] ) ;
451
+ batch. delete_range_cf ( & cf, & prefix[ ..] , & end_range[ ..] ) ;
451
452
if no_end {
452
453
let prefix = if prefix. len ( ) > end_range. len ( ) { & prefix[ ..] } else { & end_range[ ..] } ;
453
454
for result in self . iter_with_prefix ( col, prefix) {
454
455
let ( key, _) = result?;
455
- batch. delete_cf ( cf, & key[ ..] ) ;
456
+ batch. delete_cf ( & cf, & key[ ..] ) ;
456
457
}
457
458
}
458
459
} ,
459
460
} ;
460
461
}
461
462
self . stats . tally_bytes_written ( stats_total_bytes as u64 ) ;
462
463
463
- cfs. db . write_opt ( batch, & self . write_opts ) . map_err ( other_io_err)
464
+ cfs. db . write_opt ( batch, & self . write_opts ) . map_err ( other_io_err) ?;
465
+ Ok ( ( ) )
464
466
}
465
467
466
468
/// Get value by key.
@@ -470,7 +472,7 @@ impl Database {
470
472
self . stats . tally_reads ( 1 ) ;
471
473
let value = cfs
472
474
. db
473
- . get_pinned_cf_opt ( cf, key, & self . read_opts )
475
+ . get_pinned_cf_opt ( & cf, key, & self . read_opts )
474
476
. map ( |r| r. map ( |v| v. to_vec ( ) ) )
475
477
. map_err ( other_io_err) ;
476
478
@@ -521,7 +523,7 @@ impl Database {
521
523
const ESTIMATE_NUM_KEYS : & str = "rocksdb.estimate-num-keys" ;
522
524
let cfs = & self . inner ;
523
525
let cf = cfs. cf ( col as usize ) ?;
524
- match cfs. db . property_int_value_cf ( cf, ESTIMATE_NUM_KEYS ) {
526
+ match cfs. db . property_int_value_cf ( & cf, ESTIMATE_NUM_KEYS ) {
525
527
Ok ( estimate) => Ok ( estimate. unwrap_or_default ( ) ) ,
526
528
Err ( err_string) => Err ( other_io_err ( err_string) ) ,
527
529
}
0 commit comments