Fix clippy warnings (#627)

master
Federico Guerinoni 2 years ago committed by GitHub
parent 3a46074c36
commit 5a3ced8d3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      librocksdb-sys/src/test.rs
  2. 5
      src/backup.rs
  3. 15
      src/db.rs
  4. 125
      src/db_options.rs
  5. 4
      src/perf.rs
  6. 2
      src/slice_transform.rs
  7. 3
      tests/test_merge_operator.rs

@ -37,7 +37,7 @@ fn internal() {
rocksdb_options_increase_parallelism(opts, 0);
rocksdb_options_optimize_level_style_compaction(opts, 0);
rocksdb_options_set_create_if_missing(opts, true as c_uchar);
rocksdb_options_set_create_if_missing(opts, u8::from(true));
let rustpath = "_rust_rocksdb_internaltest";
let cpath = CString::new(rustpath).unwrap();

@ -15,7 +15,6 @@
use crate::{ffi, Error, DB};
use libc::{c_int, c_uchar};
use std::ffi::CString;
use std::path::Path;
@ -93,7 +92,7 @@ impl BackupEngine {
ffi_try!(ffi::rocksdb_backup_engine_create_new_backup_flush(
self.inner,
db.inner,
flush_before_backup as c_uchar,
u8::from(flush_before_backup),
));
Ok(())
}
@ -268,7 +267,7 @@ impl BackupEngineOptions {
impl RestoreOptions {
pub fn set_keep_log_files(&mut self, keep_log_files: bool) {
unsafe {
ffi::rocksdb_restore_options_set_keep_log_files(self.inner, keep_log_files as c_int);
ffi::rocksdb_restore_options_set_keep_log_files(self.inner, i32::from(keep_log_files));
}
}
}

@ -26,7 +26,7 @@ use crate::{
WriteBatch, WriteOptions, DEFAULT_COLUMN_FAMILY_NAME,
};
use libc::{self, c_char, c_int, c_uchar, c_void, size_t};
use libc::{self, c_char, c_int, c_void, size_t};
use std::collections::BTreeMap;
use std::ffi::{CStr, CString};
use std::fmt;
@ -331,7 +331,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
/// Opens the database with a Time to Live compaction filter and column family names.
///
/// Column families opened using this function will be created with default `Options`.
/// Column families opened using this function will be created with default `Options`.
pub fn open_cf_with_ttl<P, I, N>(
opts: &Options,
path: P,
@ -614,7 +614,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
} => ffi_try!(ffi::rocksdb_open_for_read_only(
opts.inner,
cpath.as_ptr() as *const _,
error_if_log_file_exist as c_uchar,
u8::from(error_if_log_file_exist),
)),
AccessType::ReadWrite => {
ffi_try!(ffi::rocksdb_open(opts.inner, cpath.as_ptr() as *const _))
@ -636,13 +636,14 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
Ok(db)
}
#[allow(clippy::pedantic)]
fn open_cf_raw(
opts: &Options,
cpath: &CString,
cfs_v: &[ColumnFamilyDescriptor],
cfnames: &[*const c_char],
cfopts: &[*const ffi::rocksdb_options_t],
cfhandles: &mut Vec<*mut ffi::rocksdb_column_family_handle_t>,
cfhandles: &mut [*mut ffi::rocksdb_column_family_handle_t],
access_type: &AccessType,
) -> Result<*mut ffi::rocksdb_t, Error> {
let db = unsafe {
@ -656,7 +657,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
cfnames.as_ptr(),
cfopts.as_ptr(),
cfhandles.as_mut_ptr(),
error_if_log_file_exist as c_uchar,
u8::from(error_if_log_file_exist),
)),
AccessType::ReadWrite => ffi_try!(ffi::rocksdb_open_column_families(
opts.inner,
@ -737,7 +738,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
/// the data to disk.
pub fn flush_wal(&self, sync: bool) -> Result<(), Error> {
unsafe {
ffi_try!(ffi::rocksdb_flush_wal(self.inner, sync as u8));
ffi_try!(ffi::rocksdb_flush_wal(self.inner, u8::from(sync)));
}
Ok(())
}
@ -1891,7 +1892,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
/// Request stopping background work, if wait is true wait until it's done.
pub fn cancel_all_background_work(&self, wait: bool) {
unsafe {
ffi::rocksdb_cancel_all_background_work(self.inner, wait as u8);
ffi::rocksdb_cancel_all_background_work(self.inner, u8::from(wait));
}
}

@ -495,7 +495,7 @@ impl BlockBasedOptions {
/// incompatible with block-based filters.
pub fn set_partition_filters(&mut self, size: bool) {
unsafe {
ffi::rocksdb_block_based_options_set_partition_filters(self.inner, size as c_uchar);
ffi::rocksdb_block_based_options_set_partition_filters(self.inner, u8::from(size));
}
}
@ -557,7 +557,7 @@ impl BlockBasedOptions {
/// Disable block cache
pub fn disable_cache(&mut self) {
unsafe {
ffi::rocksdb_block_based_options_set_no_block_cache(self.inner, true as c_uchar);
ffi::rocksdb_block_based_options_set_no_block_cache(self.inner, u8::from(true));
}
}
@ -636,7 +636,10 @@ impl BlockBasedOptions {
pub fn set_cache_index_and_filter_blocks(&mut self, v: bool) {
unsafe {
ffi::rocksdb_block_based_options_set_cache_index_and_filter_blocks(self.inner, v as u8);
ffi::rocksdb_block_based_options_set_cache_index_and_filter_blocks(
self.inner,
u8::from(v),
);
}
}
@ -668,7 +671,7 @@ impl BlockBasedOptions {
unsafe {
ffi::rocksdb_block_based_options_set_pin_l0_filter_and_index_blocks_in_cache(
self.inner,
v as c_uchar,
u8::from(v),
);
}
}
@ -684,7 +687,7 @@ impl BlockBasedOptions {
unsafe {
ffi::rocksdb_block_based_options_set_pin_top_level_index_and_filter(
self.inner,
v as c_uchar,
u8::from(v),
);
}
}
@ -769,7 +772,7 @@ impl BlockBasedOptions {
/// Defaults to true.
pub fn set_whole_key_filtering(&mut self, v: bool) {
unsafe {
ffi::rocksdb_block_based_options_set_whole_key_filtering(self.inner, v as u8);
ffi::rocksdb_block_based_options_set_whole_key_filtering(self.inner, u8::from(v));
}
}
}
@ -829,7 +832,7 @@ impl CuckooTableOptions {
/// table property.
/// Default: false
pub fn set_identity_as_first_hash(&mut self, flag: bool) {
let v = flag as u8;
let v = u8::from(flag);
unsafe {
ffi::rocksdb_cuckoo_options_set_identity_as_first_hash(self.inner, v);
}
@ -841,7 +844,7 @@ impl CuckooTableOptions {
/// be power of two, and bit and is used to calculate hash, which is faster in general.
/// Default: true
pub fn set_use_module_hash(&mut self, flag: bool) {
let v = flag as u8;
let v = u8::from(flag);
unsafe {
ffi::rocksdb_cuckoo_options_set_use_module_hash(self.inner, v);
}
@ -954,7 +957,7 @@ impl Options {
/// ```
pub fn create_if_missing(&mut self, create_if_missing: bool) {
unsafe {
ffi::rocksdb_options_set_create_if_missing(self.inner, create_if_missing as c_uchar);
ffi::rocksdb_options_set_create_if_missing(self.inner, u8::from(create_if_missing));
}
}
@ -975,7 +978,7 @@ impl Options {
unsafe {
ffi::rocksdb_options_set_create_missing_column_families(
self.inner,
create_missing_cfs as c_uchar,
u8::from(create_missing_cfs),
);
}
}
@ -985,7 +988,7 @@ impl Options {
/// Default: false
pub fn set_error_if_exists(&mut self, enabled: bool) {
unsafe {
ffi::rocksdb_options_set_error_if_exists(self.inner, enabled as c_uchar);
ffi::rocksdb_options_set_error_if_exists(self.inner, u8::from(enabled));
}
}
@ -1003,7 +1006,7 @@ impl Options {
/// Default: false
pub fn set_paranoid_checks(&mut self, enabled: bool) {
unsafe {
ffi::rocksdb_options_set_paranoid_checks(self.inner, enabled as c_uchar);
ffi::rocksdb_options_set_paranoid_checks(self.inner, u8::from(enabled));
}
}
@ -1204,7 +1207,7 @@ impl Options {
level,
strategy,
max_dict_bytes,
enabled as c_uchar,
u8::from(enabled),
);
}
}
@ -1236,7 +1239,7 @@ impl Options {
ffi::rocksdb_options_set_bottommost_compression_options_zstd_max_train_bytes(
self.inner,
value,
enabled as c_uchar,
u8::from(enabled),
);
}
}
@ -1265,7 +1268,7 @@ impl Options {
/// Default: false.
pub fn set_level_compaction_dynamic_level_bytes(&mut self, v: bool) {
unsafe {
ffi::rocksdb_options_set_level_compaction_dynamic_level_bytes(self.inner, v as c_uchar);
ffi::rocksdb_options_set_level_compaction_dynamic_level_bytes(self.inner, u8::from(v));
}
}
@ -1441,7 +1444,7 @@ impl Options {
unsafe {
ffi::rocksdb_options_set_optimize_filters_for_hits(
self.inner,
optimize_for_hits as c_int,
i32::from(optimize_for_hits),
);
}
}
@ -1518,7 +1521,7 @@ impl Options {
/// ```
pub fn set_use_fsync(&mut self, useit: bool) {
unsafe {
ffi::rocksdb_options_set_use_fsync(self.inner, useit as c_int);
ffi::rocksdb_options_set_use_fsync(self.inner, i32::from(useit));
}
}
@ -1630,7 +1633,7 @@ impl Options {
/// ```
pub fn set_allow_concurrent_memtable_write(&mut self, allow: bool) {
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, u8::from(allow));
}
}
@ -1644,7 +1647,7 @@ impl Options {
unsafe {
ffi::rocksdb_options_set_enable_write_thread_adaptive_yield(
self.inner,
enabled as c_uchar,
u8::from(enabled),
);
}
}
@ -1681,7 +1684,7 @@ impl Options {
/// ```
pub fn set_use_direct_reads(&mut self, enabled: bool) {
unsafe {
ffi::rocksdb_options_set_use_direct_reads(self.inner, enabled as c_uchar);
ffi::rocksdb_options_set_use_direct_reads(self.inner, u8::from(enabled));
}
}
@ -1707,7 +1710,7 @@ impl Options {
unsafe {
ffi::rocksdb_options_set_use_direct_io_for_flush_and_compaction(
self.inner,
enabled as c_uchar,
u8::from(enabled),
);
}
}
@ -1717,7 +1720,7 @@ impl Options {
/// Default: true
pub fn set_is_fd_close_on_exec(&mut self, enabled: bool) {
unsafe {
ffi::rocksdb_options_set_is_fd_close_on_exec(self.inner, enabled as c_uchar);
ffi::rocksdb_options_set_is_fd_close_on_exec(self.inner, u8::from(enabled));
}
}
@ -2123,7 +2126,7 @@ impl Options {
/// Default: false
pub fn set_unordered_write(&mut self, unordered: bool) {
unsafe {
ffi::rocksdb_options_set_unordered_write(self.inner, unordered as c_uchar);
ffi::rocksdb_options_set_unordered_write(self.inner, u8::from(unordered));
}
}
@ -2233,7 +2236,7 @@ impl Options {
/// ```
pub fn set_disable_auto_compactions(&mut self, disable: bool) {
unsafe {
ffi::rocksdb_options_set_disable_auto_compactions(self.inner, disable as c_int);
ffi::rocksdb_options_set_disable_auto_compactions(self.inner, i32::from(disable));
}
}
@ -2296,7 +2299,7 @@ impl Options {
/// Default: false.
pub fn set_inplace_update_support(&mut self, enabled: bool) {
unsafe {
ffi::rocksdb_options_set_inplace_update_support(self.inner, enabled as c_uchar);
ffi::rocksdb_options_set_inplace_update_support(self.inner, u8::from(enabled));
}
}
@ -2339,7 +2342,7 @@ impl Options {
unsafe {
ffi::rocksdb_options_set_skip_checking_sst_file_sizes_on_db_open(
self.inner,
value as c_uchar,
u8::from(value),
);
}
}
@ -2395,7 +2398,7 @@ impl Options {
/// Default: false
pub fn set_enable_pipelined_write(&mut self, value: bool) {
unsafe {
ffi::rocksdb_options_set_enable_pipelined_write(self.inner, value as c_uchar);
ffi::rocksdb_options_set_enable_pipelined_write(self.inner, u8::from(value));
}
}
@ -2529,7 +2532,7 @@ impl Options {
/// ```
pub fn set_report_bg_io_stats(&mut self, enable: bool) {
unsafe {
ffi::rocksdb_options_set_report_bg_io_stats(self.inner, enable as c_int);
ffi::rocksdb_options_set_report_bg_io_stats(self.inner, i32::from(enable));
}
}
@ -2635,7 +2638,7 @@ impl Options {
/// Default: `true`
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);
ffi::rocksdb_options_set_advise_random_on_open(self.inner, u8::from(advise));
}
}
@ -2659,7 +2662,7 @@ impl Options {
/// Default: false
pub fn set_use_adaptive_mutex(&mut self, enabled: bool) {
unsafe {
ffi::rocksdb_options_set_use_adaptive_mutex(self.inner, enabled as c_uchar);
ffi::rocksdb_options_set_use_adaptive_mutex(self.inner, u8::from(enabled));
}
}
@ -2777,7 +2780,7 @@ impl Options {
/// Default: false
pub fn set_skip_stats_update_on_db_open(&mut self, skip: bool) {
unsafe {
ffi::rocksdb_options_set_skip_stats_update_on_db_open(self.inner, skip as c_uchar);
ffi::rocksdb_options_set_skip_stats_update_on_db_open(self.inner, u8::from(skip));
}
}
@ -2813,7 +2816,7 @@ impl Options {
/// ```
pub fn set_allow_mmap_writes(&mut self, is_enabled: bool) {
unsafe {
ffi::rocksdb_options_set_allow_mmap_writes(self.inner, is_enabled as c_uchar);
ffi::rocksdb_options_set_allow_mmap_writes(self.inner, u8::from(is_enabled));
}
}
@ -2831,7 +2834,7 @@ impl Options {
/// ```
pub fn set_allow_mmap_reads(&mut self, is_enabled: bool) {
unsafe {
ffi::rocksdb_options_set_allow_mmap_reads(self.inner, is_enabled as c_uchar);
ffi::rocksdb_options_set_allow_mmap_reads(self.inner, u8::from(is_enabled));
}
}
@ -2851,7 +2854,7 @@ impl Options {
/// ```
pub fn set_manual_wal_flush(&mut self, is_enabled: bool) {
unsafe {
ffi::rocksdb_options_set_manual_wal_flush(self.inner, is_enabled as c_uchar);
ffi::rocksdb_options_set_manual_wal_flush(self.inner, u8::from(is_enabled));
}
}
@ -2874,7 +2877,7 @@ impl Options {
/// ```
pub fn set_atomic_flush(&mut self, atomic_flush: bool) {
unsafe {
ffi::rocksdb_options_set_atomic_flush(self.inner, atomic_flush as c_uchar);
ffi::rocksdb_options_set_atomic_flush(self.inner, u8::from(atomic_flush));
}
}
@ -3012,7 +3015,7 @@ impl Options {
/// Default: false
pub fn set_dump_malloc_stats(&mut self, enabled: bool) {
unsafe {
ffi::rocksdb_options_set_dump_malloc_stats(self.inner, enabled as c_uchar);
ffi::rocksdb_options_set_dump_malloc_stats(self.inner, u8::from(enabled));
}
}
@ -3027,7 +3030,7 @@ impl Options {
unsafe {
ffi::rocksdb_options_set_memtable_whole_key_filtering(
self.inner,
whole_key_filter as c_uchar,
u8::from(whole_key_filter),
);
}
}
@ -3041,7 +3044,7 @@ impl Options {
/// Dynamically changeable through SetOptions() API
pub fn set_enable_blob_files(&mut self, val: bool) {
unsafe {
ffi::rocksdb_options_set_enable_blob_files(self.inner, val as _);
ffi::rocksdb_options_set_enable_blob_files(self.inner, u8::from(val));
}
}
@ -3080,7 +3083,7 @@ impl Options {
/// Dynamically changeable through SetOptions() API
pub fn set_enable_blob_gc(&mut self, val: bool) {
unsafe {
ffi::rocksdb_options_set_enable_blob_gc(self.inner, val as _);
ffi::rocksdb_options_set_enable_blob_gc(self.inner, u8::from(val));
}
}
@ -3149,7 +3152,7 @@ impl FlushOptions {
/// ```
pub fn set_wait(&mut self, wait: bool) {
unsafe {
ffi::rocksdb_flushoptions_set_wait(self.inner, wait as c_uchar);
ffi::rocksdb_flushoptions_set_wait(self.inner, u8::from(wait));
}
}
}
@ -3178,7 +3181,7 @@ impl WriteOptions {
/// Default: false
pub fn set_sync(&mut self, sync: bool) {
unsafe {
ffi::rocksdb_writeoptions_set_sync(self.inner, sync as c_uchar);
ffi::rocksdb_writeoptions_set_sync(self.inner, u8::from(sync));
}
}
@ -3189,7 +3192,7 @@ impl WriteOptions {
/// Default: false
pub fn disable_wal(&mut self, disable: bool) {
unsafe {
ffi::rocksdb_writeoptions_disable_WAL(self.inner, disable as c_int);
ffi::rocksdb_writeoptions_disable_WAL(self.inner, i32::from(disable));
}
}
@ -3202,7 +3205,7 @@ impl WriteOptions {
unsafe {
ffi::rocksdb_writeoptions_set_ignore_missing_column_families(
self.inner,
ignore as c_uchar,
u8::from(ignore),
);
}
}
@ -3213,7 +3216,7 @@ impl WriteOptions {
/// Default: false
pub fn set_no_slowdown(&mut self, no_slowdown: bool) {
unsafe {
ffi::rocksdb_writeoptions_set_no_slowdown(self.inner, no_slowdown as c_uchar);
ffi::rocksdb_writeoptions_set_no_slowdown(self.inner, u8::from(no_slowdown));
}
}
@ -3226,7 +3229,7 @@ impl WriteOptions {
/// Default: false
pub fn set_low_pri(&mut self, v: bool) {
unsafe {
ffi::rocksdb_writeoptions_set_low_pri(self.inner, v as c_uchar);
ffi::rocksdb_writeoptions_set_low_pri(self.inner, u8::from(v));
}
}
@ -3239,7 +3242,7 @@ impl WriteOptions {
/// Default: false
pub fn set_memtable_insert_hint_per_batch(&mut self, v: bool) {
unsafe {
ffi::rocksdb_writeoptions_set_memtable_insert_hint_per_batch(self.inner, v as c_uchar);
ffi::rocksdb_writeoptions_set_memtable_insert_hint_per_batch(self.inner, u8::from(v));
}
}
}
@ -3278,7 +3281,7 @@ impl ReadOptions {
/// Default: true
pub fn fill_cache(&mut self, v: bool) {
unsafe {
ffi::rocksdb_readoptions_set_fill_cache(self.inner, v as c_uchar);
ffi::rocksdb_readoptions_set_fill_cache(self.inner, u8::from(v));
}
}
@ -3347,7 +3350,7 @@ impl ReadOptions {
/// Default: false
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);
ffi::rocksdb_readoptions_set_prefix_same_as_start(self.inner, u8::from(v));
}
}
@ -3360,7 +3363,7 @@ impl ReadOptions {
/// changing implementation of prefix extractor.
pub fn set_total_order_seek(&mut self, v: bool) {
unsafe {
ffi::rocksdb_readoptions_set_total_order_seek(self.inner, v as c_uchar);
ffi::rocksdb_readoptions_set_total_order_seek(self.inner, u8::from(v));
}
}
@ -3383,7 +3386,7 @@ impl ReadOptions {
unsafe {
ffi::rocksdb_readoptions_set_background_purge_on_iterator_cleanup(
self.inner,
v as c_uchar,
u8::from(v),
);
}
}
@ -3395,7 +3398,7 @@ impl ReadOptions {
/// Default: false
pub fn set_ignore_range_deletions(&mut self, v: bool) {
unsafe {
ffi::rocksdb_readoptions_set_ignore_range_deletions(self.inner, v as c_uchar);
ffi::rocksdb_readoptions_set_ignore_range_deletions(self.inner, u8::from(v));
}
}
@ -3405,7 +3408,7 @@ impl ReadOptions {
/// Default: true
pub fn set_verify_checksums(&mut self, v: bool) {
unsafe {
ffi::rocksdb_readoptions_set_verify_checksums(self.inner, v as c_uchar);
ffi::rocksdb_readoptions_set_verify_checksums(self.inner, u8::from(v));
}
}
@ -3431,7 +3434,7 @@ impl ReadOptions {
/// or seek_to_last are not supported.
pub fn set_tailing(&mut self, v: bool) {
unsafe {
ffi::rocksdb_readoptions_set_tailing(self.inner, v as c_uchar);
ffi::rocksdb_readoptions_set_tailing(self.inner, u8::from(v));
}
}
@ -3445,7 +3448,7 @@ impl ReadOptions {
/// Default: false
pub fn set_pin_data(&mut self, v: bool) {
unsafe {
ffi::rocksdb_readoptions_set_pin_data(self.inner, v as c_uchar);
ffi::rocksdb_readoptions_set_pin_data(self.inner, u8::from(v));
}
}
}
@ -3466,7 +3469,7 @@ impl IngestExternalFileOptions {
/// Can be set to true to move the files instead of copying them.
pub fn set_move_files(&mut self, v: bool) {
unsafe {
ffi::rocksdb_ingestexternalfileoptions_set_move_files(self.inner, v as c_uchar);
ffi::rocksdb_ingestexternalfileoptions_set_move_files(self.inner, u8::from(v));
}
}
@ -3476,7 +3479,7 @@ impl IngestExternalFileOptions {
unsafe {
ffi::rocksdb_ingestexternalfileoptions_set_snapshot_consistency(
self.inner,
v as c_uchar,
u8::from(v),
);
}
}
@ -3485,7 +3488,7 @@ impl IngestExternalFileOptions {
/// overlaps with existing keys or tombstones in the DB.
pub fn set_allow_global_seqno(&mut self, v: bool) {
unsafe {
ffi::rocksdb_ingestexternalfileoptions_set_allow_global_seqno(self.inner, v as c_uchar);
ffi::rocksdb_ingestexternalfileoptions_set_allow_global_seqno(self.inner, u8::from(v));
}
}
@ -3495,7 +3498,7 @@ impl IngestExternalFileOptions {
unsafe {
ffi::rocksdb_ingestexternalfileoptions_set_allow_blocking_flush(
self.inner,
v as c_uchar,
u8::from(v),
);
}
}
@ -3509,7 +3512,7 @@ impl IngestExternalFileOptions {
/// All files will be ingested at the bottommost level with seqno=0.
pub fn set_ingest_behind(&mut self, v: bool) {
unsafe {
ffi::rocksdb_ingestexternalfileoptions_set_ingest_behind(self.inner, v as c_uchar);
ffi::rocksdb_ingestexternalfileoptions_set_ingest_behind(self.inner, u8::from(v));
}
}
}
@ -3820,7 +3823,7 @@ impl CompactOptions {
/// and wait for existing automatic compaction jobs to finish.
pub fn set_exclusive_manual_compaction(&mut self, v: bool) {
unsafe {
ffi::rocksdb_compactoptions_set_exclusive_manual_compaction(self.inner, v as c_uchar);
ffi::rocksdb_compactoptions_set_exclusive_manual_compaction(self.inner, u8::from(v));
}
}
@ -3835,7 +3838,7 @@ impl CompactOptions {
/// of holding the data or given level (specified non-negative target_level).
pub fn set_change_level(&mut self, v: bool) {
unsafe {
ffi::rocksdb_compactoptions_set_change_level(self.inner, v as c_uchar);
ffi::rocksdb_compactoptions_set_change_level(self.inner, u8::from(v));
}
}

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use libc::{c_int, c_uchar, c_void};
use libc::{c_int, c_void};
use crate::{ffi, ffi_util::from_cstr, Cache, Error, DB};
@ -152,7 +152,7 @@ impl PerfContext {
/// Get the report on perf
pub fn report(&self, exclude_zero_counters: bool) -> String {
unsafe {
let ptr = ffi::rocksdb_perfcontext_report(self.inner, exclude_zero_counters as c_uchar);
let ptr = ffi::rocksdb_perfcontext_report(self.inner, u8::from(exclude_zero_counters));
let report = from_cstr(ptr);
libc::free(ptr as *mut c_void);
report

@ -112,5 +112,5 @@ pub unsafe extern "C" fn in_domain_callback(
let cb = &mut *(raw_cb as *mut TransformCallback);
let key = slice::from_raw_parts(raw_key as *const u8, key_len as usize);
cb.in_domain_fn
.map_or(0xff, |in_domain| in_domain(key) as u8)
.map_or(0xff, |in_domain| u8::from(in_domain(key)))
}

@ -115,8 +115,7 @@ fn test_counting_full_merge(
operands: &MergeOperands,
) -> Option<Vec<u8>> {
let mut counts = existing_val
.map(ValueCounts::from_slice)
.flatten()
.and_then(ValueCounts::from_slice)
.unwrap_or_default();
for op in operands {

Loading…
Cancel
Save