Fixes suggested by clippy (#547)

master
Oleksandr Anyshchenko 3 years ago committed by GitHub
parent cd7fe07a13
commit cc3a2bec59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/backup.rs
  2. 4
      src/checkpoint.rs
  3. 10
      src/db.rs
  4. 82
      src/db_options.rs
  5. 1
      src/lib.rs
  6. 4
      src/sst_file_writer.rs
  7. 4
      src/write_batch.rs

@ -61,7 +61,9 @@ impl BackupEngine {
}; };
let be: *mut ffi::rocksdb_backup_engine_t; let be: *mut ffi::rocksdb_backup_engine_t;
unsafe { be = ffi_try!(ffi::rocksdb_backup_engine_open(opts.inner, cpath.as_ptr())) } unsafe {
be = ffi_try!(ffi::rocksdb_backup_engine_open(opts.inner, cpath.as_ptr()));
}
if be.is_null() { if be.is_null() {
return Err(Error::new("Could not initialize backup engine.".to_owned())); return Err(Error::new("Could not initialize backup engine.".to_owned()));
@ -204,7 +206,7 @@ impl BackupEngine {
backup_id: ffi::rocksdb_backup_engine_info_backup_id(i, index), backup_id: ffi::rocksdb_backup_engine_info_backup_id(i, index),
size: ffi::rocksdb_backup_engine_info_size(i, index), size: ffi::rocksdb_backup_engine_info_size(i, index),
num_files: ffi::rocksdb_backup_engine_info_number_files(i, index), num_files: ffi::rocksdb_backup_engine_info_number_files(i, index),
}) });
} }
// destroy backup info object // destroy backup info object

@ -40,7 +40,9 @@ impl<'db> Checkpoint<'db> {
pub fn new(db: &'db DB) -> Result<Self, Error> { pub fn new(db: &'db DB) -> Result<Self, Error> {
let checkpoint: *mut ffi::rocksdb_checkpoint_t; let checkpoint: *mut ffi::rocksdb_checkpoint_t;
unsafe { checkpoint = ffi_try!(ffi::rocksdb_checkpoint_object_create(db.inner)) }; unsafe {
checkpoint = ffi_try!(ffi::rocksdb_checkpoint_object_create(db.inner));
}
if checkpoint.is_null() { if checkpoint.is_null() {
return Err(Error::new("Could not create checkpoint object.".to_owned())); return Err(Error::new("Could not create checkpoint object.".to_owned()));

@ -431,7 +431,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
&cfnames, &cfnames,
&cfopts, &cfopts,
&mut cfhandles, &mut cfhandles,
&access_type, access_type,
)?; )?;
for handle in &cfhandles { for handle in &cfhandles {
if handle.is_null() { if handle.is_null() {
@ -586,7 +586,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
} }
pub fn path(&self) -> &Path { pub fn path(&self) -> &Path {
&self.path.as_path() self.path.as_path()
} }
/// Flushes the WAL buffer. If `sync` is set to `true`, also syncs /// Flushes the WAL buffer. If `sync` is set to `true`, also syncs
@ -1587,7 +1587,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
let cpaths: Vec<_> = paths_v.iter().map(|path| path.as_ptr()).collect(); let cpaths: Vec<_> = paths_v.iter().map(|path| path.as_ptr()).collect();
self.ingest_external_file_raw(&opts, &paths_v, &cpaths) self.ingest_external_file_raw(opts, &paths_v, &cpaths)
} }
/// Loads a list of external SST files created with SstFileWriter into the DB for given Column Family /// Loads a list of external SST files created with SstFileWriter into the DB for given Column Family
@ -1615,7 +1615,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
let cpaths: Vec<_> = paths_v.iter().map(|path| path.as_ptr()).collect(); let cpaths: Vec<_> = paths_v.iter().map(|path| path.as_ptr()).collect();
self.ingest_external_file_raw_cf(cf, &opts, &paths_v, &cpaths) self.ingest_external_file_raw_cf(cf, opts, &paths_v, &cpaths)
} }
fn ingest_external_file_raw( fn ingest_external_file_raw(
@ -1688,7 +1688,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
end_key: largest_key, end_key: largest_key,
num_entries: ffi::rocksdb_livefiles_entries(files, i), num_entries: ffi::rocksdb_livefiles_entries(files, i),
num_deletions: ffi::rocksdb_livefiles_deletions(files, i), num_deletions: ffi::rocksdb_livefiles_deletions(files, i),
}) });
} }
// destroy livefiles metadata(s) // destroy livefiles metadata(s)

@ -451,13 +451,17 @@ impl Drop for WriteOptions {
impl Drop for ReadOptions { impl Drop for ReadOptions {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { ffi::rocksdb_readoptions_destroy(self.inner) } unsafe {
ffi::rocksdb_readoptions_destroy(self.inner);
}
} }
} }
impl Drop for IngestExternalFileOptions { impl Drop for IngestExternalFileOptions {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { ffi::rocksdb_ingestexternalfileoptions_destroy(self.inner) } unsafe {
ffi::rocksdb_ingestexternalfileoptions_destroy(self.inner);
}
} }
} }
@ -684,7 +688,9 @@ impl BlockBasedOptions {
/// ``` /// ```
pub fn set_data_block_index_type(&mut self, index_type: DataBlockIndexType) { pub fn set_data_block_index_type(&mut self, index_type: DataBlockIndexType) {
let index_t = index_type as i32; let index_t = index_type as i32;
unsafe { ffi::rocksdb_block_based_options_set_data_block_index_type(self.inner, index_t) } unsafe {
ffi::rocksdb_block_based_options_set_data_block_index_type(self.inner, index_t);
}
} }
/// Set the data block hash index utilization ratio. /// Set the data block hash index utilization ratio.
@ -695,7 +701,9 @@ impl BlockBasedOptions {
/// ///
/// Default: 0.75 /// Default: 0.75
pub fn set_data_block_hash_ratio(&mut self, ratio: f64) { pub fn set_data_block_hash_ratio(&mut self, ratio: f64) {
unsafe { ffi::rocksdb_block_based_options_set_data_block_hash_ratio(self.inner, ratio) } unsafe {
ffi::rocksdb_block_based_options_set_data_block_hash_ratio(self.inner, ratio);
}
} }
} }
@ -717,7 +725,9 @@ impl CuckooTableOptions {
/// result in larger hash tables with fewer collisions. /// result in larger hash tables with fewer collisions.
/// Default: 0.9 /// Default: 0.9
pub fn set_hash_ratio(&mut self, ratio: f64) { pub fn set_hash_ratio(&mut self, ratio: f64) {
unsafe { ffi::rocksdb_cuckoo_options_set_hash_ratio(self.inner, ratio) } unsafe {
ffi::rocksdb_cuckoo_options_set_hash_ratio(self.inner, ratio);
}
} }
/// A property used by builder to determine the depth to go to /// A property used by builder to determine the depth to go to
@ -727,7 +737,9 @@ impl CuckooTableOptions {
/// lookups but take more time to build. /// lookups but take more time to build.
/// Default: 100 /// Default: 100
pub fn set_max_search_depth(&mut self, depth: u32) { pub fn set_max_search_depth(&mut self, depth: u32) {
unsafe { ffi::rocksdb_cuckoo_options_set_max_search_depth(self.inner, depth) } unsafe {
ffi::rocksdb_cuckoo_options_set_max_search_depth(self.inner, depth);
}
} }
/// In case of collision while inserting, the builder /// In case of collision while inserting, the builder
@ -737,7 +749,9 @@ impl CuckooTableOptions {
/// of collisions. /// of collisions.
/// Default: 5 /// Default: 5
pub fn set_cuckoo_block_size(&mut self, size: u32) { pub fn set_cuckoo_block_size(&mut self, size: u32) {
unsafe { ffi::rocksdb_cuckoo_options_set_cuckoo_block_size(self.inner, size) } unsafe {
ffi::rocksdb_cuckoo_options_set_cuckoo_block_size(self.inner, size);
}
} }
/// If this option is enabled, user key is treated as uint64_t and its value /// If this option is enabled, user key is treated as uint64_t and its value
@ -747,7 +761,9 @@ impl CuckooTableOptions {
/// Default: false /// Default: false
pub fn set_identity_as_first_hash(&mut self, flag: bool) { pub fn set_identity_as_first_hash(&mut self, flag: bool) {
let v = flag as u8; let v = flag as u8;
unsafe { ffi::rocksdb_cuckoo_options_set_identity_as_first_hash(self.inner, v) } unsafe {
ffi::rocksdb_cuckoo_options_set_identity_as_first_hash(self.inner, v);
}
} }
/// If this option is set to true, module is used during hash calculation. /// If this option is set to true, module is used during hash calculation.
@ -757,7 +773,9 @@ impl CuckooTableOptions {
/// Default: true /// Default: true
pub fn set_use_module_hash(&mut self, flag: bool) { pub fn set_use_module_hash(&mut self, flag: bool) {
let v = flag as u8; let v = flag as u8;
unsafe { ffi::rocksdb_cuckoo_options_set_use_module_hash(self.inner, v) } unsafe {
ffi::rocksdb_cuckoo_options_set_use_module_hash(self.inner, v);
}
} }
} }
@ -1006,7 +1024,7 @@ impl Options {
self.inner, self.inner,
level_types.as_mut_ptr(), level_types.as_mut_ptr(),
level_types.len() as size_t, level_types.len() as size_t,
) );
} }
} }
@ -1231,7 +1249,9 @@ impl Options {
} }
pub fn set_prefix_extractor(&mut self, prefix_extractor: SliceTransform) { pub fn set_prefix_extractor(&mut self, prefix_extractor: SliceTransform) {
unsafe { ffi::rocksdb_options_set_prefix_extractor(self.inner, prefix_extractor.inner) } unsafe {
ffi::rocksdb_options_set_prefix_extractor(self.inner, prefix_extractor.inner);
}
} }
#[deprecated( #[deprecated(
@ -1340,7 +1360,9 @@ impl Options {
/// opts.set_use_fsync(true); /// opts.set_use_fsync(true);
/// ``` /// ```
pub fn set_use_fsync(&mut self, useit: bool) { pub fn set_use_fsync(&mut self, useit: bool) {
unsafe { ffi::rocksdb_options_set_use_fsync(self.inner, useit as c_int) } unsafe {
ffi::rocksdb_options_set_use_fsync(self.inner, useit as c_int);
}
} }
/// Specifies the absolute info LOG dir. /// Specifies the absolute info LOG dir.
@ -1432,7 +1454,7 @@ impl Options {
/// ``` /// ```
pub fn set_allow_concurrent_memtable_write(&mut self, allow: bool) { pub fn set_allow_concurrent_memtable_write(&mut self, allow: bool) {
unsafe { unsafe {
ffi::rocksdb_options_set_allow_concurrent_memtable_write(self.inner, allow as c_uchar) ffi::rocksdb_options_set_allow_concurrent_memtable_write(self.inner, allow as c_uchar);
} }
} }
@ -1595,7 +1617,7 @@ impl Options {
/// Dynamically changeable through SetOptions() API /// Dynamically changeable through SetOptions() API
pub fn set_target_file_size_multiplier(&mut self, multiplier: i32) { pub fn set_target_file_size_multiplier(&mut self, multiplier: i32) {
unsafe { unsafe {
ffi::rocksdb_options_set_target_file_size_multiplier(self.inner, multiplier as c_int) ffi::rocksdb_options_set_target_file_size_multiplier(self.inner, multiplier as c_int);
} }
} }
@ -2045,7 +2067,9 @@ impl Options {
/// opts.set_disable_auto_compactions(true); /// opts.set_disable_auto_compactions(true);
/// ``` /// ```
pub fn set_disable_auto_compactions(&mut self, disable: bool) { pub fn set_disable_auto_compactions(&mut self, disable: bool) {
unsafe { ffi::rocksdb_options_set_disable_auto_compactions(self.inner, disable as c_int) } unsafe {
ffi::rocksdb_options_set_disable_auto_compactions(self.inner, disable as c_int);
}
} }
/// SetMemtableHugePageSize sets the page size for huge page for /// SetMemtableHugePageSize sets the page size for huge page for
@ -2060,7 +2084,9 @@ impl Options {
/// ///
/// Dynamically changeable through SetOptions() API /// Dynamically changeable through SetOptions() API
pub fn set_memtable_huge_page_size(&mut self, size: size_t) { pub fn set_memtable_huge_page_size(&mut self, size: size_t) {
unsafe { ffi::rocksdb_options_set_memtable_huge_page_size(self.inner, size) } unsafe {
ffi::rocksdb_options_set_memtable_huge_page_size(self.inner, size);
}
} }
/// Sets the maximum number of successive merge operations on a key in the memtable. /// Sets the maximum number of successive merge operations on a key in the memtable.
@ -2132,7 +2158,7 @@ impl Options {
self.inner, self.inner,
level_values.as_ptr() as *mut c_int, level_values.as_ptr() as *mut c_int,
count, count,
) );
} }
} }
@ -2149,7 +2175,7 @@ impl Options {
ffi::rocksdb_options_set_skip_checking_sst_file_sizes_on_db_open( ffi::rocksdb_options_set_skip_checking_sst_file_sizes_on_db_open(
self.inner, self.inner,
value as c_uchar, value as c_uchar,
) );
} }
} }
@ -2184,7 +2210,9 @@ impl Options {
/// be set to the value of 'max_write_buffer_number * write_buffer_size' /// be set to the value of 'max_write_buffer_number * write_buffer_size'
/// if it is not explicitly set by the user. Otherwise, the default is 0. /// if it is not explicitly set by the user. Otherwise, the default is 0.
pub fn set_max_write_buffer_size_to_maintain(&mut self, size: i64) { pub fn set_max_write_buffer_size_to_maintain(&mut self, size: i64) {
unsafe { ffi::rocksdb_options_set_max_write_buffer_size_to_maintain(self.inner, size) } unsafe {
ffi::rocksdb_options_set_max_write_buffer_size_to_maintain(self.inner, size);
}
} }
/// By default, a single write thread queue is maintained. The thread gets /// By default, a single write thread queue is maintained. The thread gets
@ -2201,7 +2229,9 @@ impl Options {
/// ///
/// Default: false /// Default: false
pub fn set_enable_pipelined_write(&mut self, value: bool) { pub fn set_enable_pipelined_write(&mut self, value: bool) {
unsafe { ffi::rocksdb_options_set_enable_pipelined_write(self.inner, value as c_uchar) } unsafe {
ffi::rocksdb_options_set_enable_pipelined_write(self.inner, value as c_uchar);
}
} }
/// Defines the underlying memtable implementation. /// Defines the underlying memtable implementation.
@ -2439,7 +2469,9 @@ impl Options {
/// ///
/// Default: `true` /// Default: `true`
pub fn set_advise_random_on_open(&mut self, advise: bool) { pub fn set_advise_random_on_open(&mut self, advise: bool) {
unsafe { ffi::rocksdb_options_set_advise_random_on_open(self.inner, advise as c_uchar) } unsafe {
ffi::rocksdb_options_set_advise_random_on_open(self.inner, advise as c_uchar);
}
} }
/// Specifies the file access pattern once a compaction is started. /// Specifies the file access pattern once a compaction is started.
@ -3110,7 +3142,9 @@ impl ReadOptions {
/// ///
/// Default: false /// Default: false
pub fn set_prefix_same_as_start(&mut self, v: bool) { pub fn set_prefix_same_as_start(&mut self, v: bool) {
unsafe { ffi::rocksdb_readoptions_set_prefix_same_as_start(self.inner, v as c_uchar) } unsafe {
ffi::rocksdb_readoptions_set_prefix_same_as_start(self.inner, v as c_uchar);
}
} }
/// Enable a total order seek regardless of index format (e.g. hash index) /// Enable a total order seek regardless of index format (e.g. hash index)
@ -3121,7 +3155,9 @@ impl ReadOptions {
/// block based table. It provides a way to read existing data after /// block based table. It provides a way to read existing data after
/// changing implementation of prefix extractor. /// changing implementation of prefix extractor.
pub fn set_total_order_seek(&mut self, v: bool) { pub fn set_total_order_seek(&mut self, v: bool) {
unsafe { ffi::rocksdb_readoptions_set_total_order_seek(self.inner, v as c_uchar) } unsafe {
ffi::rocksdb_readoptions_set_total_order_seek(self.inner, v as c_uchar);
}
} }
/// Sets a threshold for the number of keys that can be skipped /// Sets a threshold for the number of keys that can be skipped

@ -60,7 +60,6 @@
clippy::cast_possible_wrap, clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_possible_wrap, clippy::cast_possible_truncation, clippy::cast_sign_loss,
// Next lints produce too much noise/false positives. // Next lints produce too much noise/false positives.
clippy::module_name_repetitions, clippy::similar_names, clippy::must_use_candidate, clippy::module_name_repetitions, clippy::similar_names, clippy::must_use_candidate,
clippy::pub_enum_variant_names,
// '... may panic' lints. // '... may panic' lints.
clippy::indexing_slicing, clippy::indexing_slicing,
// Too much work to fix. // Too much work to fix.

@ -94,7 +94,9 @@ impl<'a> SstFileWriter<'a> {
/// returns the current file size /// returns the current file size
pub fn file_size(&self) -> u64 { pub fn file_size(&self) -> u64 {
let mut file_size: u64 = 0; let mut file_size: u64 = 0;
unsafe { ffi::rocksdb_sstfilewriter_file_size(self.inner, &mut file_size) }; unsafe {
ffi::rocksdb_sstfilewriter_file_size(self.inner, &mut file_size);
}
file_size file_size
} }

@ -276,7 +276,9 @@ impl Default for WriteBatch {
impl Drop for WriteBatch { impl Drop for WriteBatch {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { ffi::rocksdb_writebatch_destroy(self.inner) } unsafe {
ffi::rocksdb_writebatch_destroy(self.inner);
}
} }
} }

Loading…
Cancel
Save