Small clean-ups (including fix for UB) (#616)

master
Niklas Fiekas 2 years ago committed by GitHub
parent ac4ffa3ebe
commit 701d46198b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/backup.rs
  2. 29
      src/db.rs
  3. 143
      src/db_options.rs
  4. 5
      src/perf.rs
  5. 7
      src/slice_transform.rs

@ -15,6 +15,7 @@
use crate::{ffi, ffi_util::to_cpath, Error, DB};
use libc::{c_int, c_uchar};
use std::path::Path;
/// Represents information of a backup including timestamp of the backup
@ -82,7 +83,7 @@ impl BackupEngine {
ffi_try!(ffi::rocksdb_backup_engine_create_new_backup_flush(
self.inner,
db.inner,
u8::from(flush_before_backup),
c_uchar::from(flush_before_backup),
));
Ok(())
}
@ -219,7 +220,10 @@ 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, i32::from(keep_log_files));
ffi::rocksdb_restore_options_set_keep_log_files(
self.inner,
c_int::from(keep_log_files),
);
}
}
}

@ -26,7 +26,7 @@ use crate::{
WriteBatch, WriteOptions, DEFAULT_COLUMN_FAMILY_NAME,
};
use libc::{self, c_char, c_int, c_void, size_t};
use libc::{self, c_char, c_int, c_uchar, c_void, size_t};
use std::collections::BTreeMap;
use std::ffi::{CStr, CString};
use std::fmt;
@ -638,22 +638,22 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
error_if_log_file_exist,
} => ffi_try!(ffi::rocksdb_open_for_read_only(
opts.inner,
cpath.as_ptr() as *const _,
u8::from(error_if_log_file_exist),
cpath.as_ptr(),
c_uchar::from(error_if_log_file_exist),
)),
AccessType::ReadWrite => {
ffi_try!(ffi::rocksdb_open(opts.inner, cpath.as_ptr() as *const _))
ffi_try!(ffi::rocksdb_open(opts.inner, cpath.as_ptr()))
}
AccessType::Secondary { secondary_path } => {
ffi_try!(ffi::rocksdb_open_as_secondary(
opts.inner,
cpath.as_ptr() as *const _,
to_cpath(secondary_path)?.as_ptr() as *const _,
cpath.as_ptr(),
to_cpath(secondary_path)?.as_ptr(),
))
}
AccessType::WithTTL { ttl } => ffi_try!(ffi::rocksdb_open_with_ttl(
opts.inner,
cpath.as_ptr() as *const _,
cpath.as_ptr(),
ttl.as_secs() as c_int,
)),
}
@ -682,7 +682,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
cfnames.as_ptr(),
cfopts.as_ptr(),
cfhandles.as_mut_ptr(),
u8::from(error_if_log_file_exist),
c_uchar::from(error_if_log_file_exist),
)),
AccessType::ReadWrite => ffi_try!(ffi::rocksdb_open_column_families(
opts.inner,
@ -695,8 +695,8 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
AccessType::Secondary { secondary_path } => {
ffi_try!(ffi::rocksdb_open_as_secondary_column_families(
opts.inner,
cpath.as_ptr() as *const _,
to_cpath(secondary_path)?.as_ptr() as *const _,
cpath.as_ptr(),
to_cpath(secondary_path)?.as_ptr(),
cfs_v.len() as c_int,
cfnames.as_ptr(),
cfopts.as_ptr(),
@ -704,6 +704,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
))
}
AccessType::WithTTL { ttl } => {
let ttls_v = vec![ttl.as_secs() as c_int; cfs_v.len()];
ffi_try!(ffi::rocksdb_open_column_families_with_ttl(
opts.inner,
cpath.as_ptr(),
@ -711,7 +712,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
cfnames.as_ptr(),
cfopts.as_ptr(),
cfhandles.as_mut_ptr(),
&(ttl.as_secs() as c_int) as *const _,
ttls_v.as_ptr(),
))
}
}
@ -726,7 +727,7 @@ impl<T: ThreadMode> DBWithThreadMode<T> {
unsafe {
let ptr = ffi_try!(ffi::rocksdb_list_column_families(
opts.inner,
cpath.as_ptr() as *const _,
cpath.as_ptr(),
&mut length,
));
@ -763,7 +764,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, u8::from(sync)));
ffi_try!(ffi::rocksdb_flush_wal(self.inner, c_uchar::from(sync)));
}
Ok(())
}
@ -1975,7 +1976,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, u8::from(wait));
ffi::rocksdb_cancel_all_background_work(self.inner, c_uchar::from(wait));
}
}

@ -496,7 +496,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, u8::from(size));
ffi::rocksdb_block_based_options_set_partition_filters(self.inner, c_uchar::from(size));
}
}
@ -558,7 +558,7 @@ impl BlockBasedOptions {
/// Disable block cache
pub fn disable_cache(&mut self) {
unsafe {
ffi::rocksdb_block_based_options_set_no_block_cache(self.inner, u8::from(true));
ffi::rocksdb_block_based_options_set_no_block_cache(self.inner, c_uchar::from(true));
}
}
@ -639,7 +639,7 @@ impl BlockBasedOptions {
unsafe {
ffi::rocksdb_block_based_options_set_cache_index_and_filter_blocks(
self.inner,
u8::from(v),
c_uchar::from(v),
);
}
}
@ -672,7 +672,7 @@ impl BlockBasedOptions {
unsafe {
ffi::rocksdb_block_based_options_set_pin_l0_filter_and_index_blocks_in_cache(
self.inner,
u8::from(v),
c_uchar::from(v),
);
}
}
@ -688,7 +688,7 @@ impl BlockBasedOptions {
unsafe {
ffi::rocksdb_block_based_options_set_pin_top_level_index_and_filter(
self.inner,
u8::from(v),
c_uchar::from(v),
);
}
}
@ -773,7 +773,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, u8::from(v));
ffi::rocksdb_block_based_options_set_whole_key_filtering(self.inner, c_uchar::from(v));
}
}
}
@ -833,9 +833,8 @@ impl CuckooTableOptions {
/// table property.
/// Default: false
pub fn set_identity_as_first_hash(&mut self, flag: bool) {
let v = u8::from(flag);
unsafe {
ffi::rocksdb_cuckoo_options_set_identity_as_first_hash(self.inner, v);
ffi::rocksdb_cuckoo_options_set_identity_as_first_hash(self.inner, c_uchar::from(flag));
}
}
@ -845,9 +844,8 @@ 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 = u8::from(flag);
unsafe {
ffi::rocksdb_cuckoo_options_set_use_module_hash(self.inner, v);
ffi::rocksdb_cuckoo_options_set_use_module_hash(self.inner, c_uchar::from(flag));
}
}
}
@ -958,7 +956,10 @@ impl Options {
/// ```
pub fn create_if_missing(&mut self, create_if_missing: bool) {
unsafe {
ffi::rocksdb_options_set_create_if_missing(self.inner, u8::from(create_if_missing));
ffi::rocksdb_options_set_create_if_missing(
self.inner,
c_uchar::from(create_if_missing),
);
}
}
@ -979,7 +980,7 @@ impl Options {
unsafe {
ffi::rocksdb_options_set_create_missing_column_families(
self.inner,
u8::from(create_missing_cfs),
c_uchar::from(create_missing_cfs),
);
}
}
@ -989,7 +990,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, u8::from(enabled));
ffi::rocksdb_options_set_error_if_exists(self.inner, c_uchar::from(enabled));
}
}
@ -1007,7 +1008,7 @@ impl Options {
/// Default: false
pub fn set_paranoid_checks(&mut self, enabled: bool) {
unsafe {
ffi::rocksdb_options_set_paranoid_checks(self.inner, u8::from(enabled));
ffi::rocksdb_options_set_paranoid_checks(self.inner, c_uchar::from(enabled));
}
}
@ -1208,7 +1209,7 @@ impl Options {
level,
strategy,
max_dict_bytes,
u8::from(enabled),
c_uchar::from(enabled),
);
}
}
@ -1240,7 +1241,7 @@ impl Options {
ffi::rocksdb_options_set_bottommost_compression_options_zstd_max_train_bytes(
self.inner,
value,
u8::from(enabled),
c_uchar::from(enabled),
);
}
}
@ -1255,10 +1256,7 @@ impl Options {
/// Default: `0`
pub fn set_compaction_readahead_size(&mut self, compaction_readahead_size: usize) {
unsafe {
ffi::rocksdb_options_compaction_readahead_size(
self.inner,
compaction_readahead_size as usize,
);
ffi::rocksdb_options_compaction_readahead_size(self.inner, compaction_readahead_size);
}
}
@ -1269,7 +1267,10 @@ 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, u8::from(v));
ffi::rocksdb_options_set_level_compaction_dynamic_level_bytes(
self.inner,
c_uchar::from(v),
);
}
}
@ -1445,7 +1446,7 @@ impl Options {
unsafe {
ffi::rocksdb_options_set_optimize_filters_for_hits(
self.inner,
i32::from(optimize_for_hits),
c_int::from(optimize_for_hits),
);
}
}
@ -1522,7 +1523,7 @@ impl Options {
/// ```
pub fn set_use_fsync(&mut self, useit: bool) {
unsafe {
ffi::rocksdb_options_set_use_fsync(self.inner, i32::from(useit));
ffi::rocksdb_options_set_use_fsync(self.inner, c_int::from(useit));
}
}
@ -1634,7 +1635,10 @@ impl Options {
/// ```
pub fn set_allow_concurrent_memtable_write(&mut self, allow: bool) {
unsafe {
ffi::rocksdb_options_set_allow_concurrent_memtable_write(self.inner, u8::from(allow));
ffi::rocksdb_options_set_allow_concurrent_memtable_write(
self.inner,
c_uchar::from(allow),
);
}
}
@ -1648,7 +1652,7 @@ impl Options {
unsafe {
ffi::rocksdb_options_set_enable_write_thread_adaptive_yield(
self.inner,
u8::from(enabled),
c_uchar::from(enabled),
);
}
}
@ -1685,7 +1689,7 @@ impl Options {
/// ```
pub fn set_use_direct_reads(&mut self, enabled: bool) {
unsafe {
ffi::rocksdb_options_set_use_direct_reads(self.inner, u8::from(enabled));
ffi::rocksdb_options_set_use_direct_reads(self.inner, c_uchar::from(enabled));
}
}
@ -1711,7 +1715,7 @@ impl Options {
unsafe {
ffi::rocksdb_options_set_use_direct_io_for_flush_and_compaction(
self.inner,
u8::from(enabled),
c_uchar::from(enabled),
);
}
}
@ -1721,7 +1725,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, u8::from(enabled));
ffi::rocksdb_options_set_is_fd_close_on_exec(self.inner, c_uchar::from(enabled));
}
}
@ -2127,7 +2131,7 @@ impl Options {
/// Default: false
pub fn set_unordered_write(&mut self, unordered: bool) {
unsafe {
ffi::rocksdb_options_set_unordered_write(self.inner, u8::from(unordered));
ffi::rocksdb_options_set_unordered_write(self.inner, c_uchar::from(unordered));
}
}
@ -2237,7 +2241,7 @@ impl Options {
/// ```
pub fn set_disable_auto_compactions(&mut self, disable: bool) {
unsafe {
ffi::rocksdb_options_set_disable_auto_compactions(self.inner, i32::from(disable));
ffi::rocksdb_options_set_disable_auto_compactions(self.inner, c_int::from(disable));
}
}
@ -2300,7 +2304,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, u8::from(enabled));
ffi::rocksdb_options_set_inplace_update_support(self.inner, c_uchar::from(enabled));
}
}
@ -2343,7 +2347,7 @@ impl Options {
unsafe {
ffi::rocksdb_options_set_skip_checking_sst_file_sizes_on_db_open(
self.inner,
u8::from(value),
c_uchar::from(value),
);
}
}
@ -2399,7 +2403,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, u8::from(value));
ffi::rocksdb_options_set_enable_pipelined_write(self.inner, c_uchar::from(value));
}
}
@ -2533,7 +2537,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, i32::from(enable));
ffi::rocksdb_options_set_report_bg_io_stats(self.inner, c_int::from(enable));
}
}
@ -2639,7 +2643,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, u8::from(advise));
ffi::rocksdb_options_set_advise_random_on_open(self.inner, c_uchar::from(advise));
}
}
@ -2663,7 +2667,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, u8::from(enabled));
ffi::rocksdb_options_set_use_adaptive_mutex(self.inner, c_uchar::from(enabled));
}
}
@ -2781,7 +2785,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, u8::from(skip));
ffi::rocksdb_options_set_skip_stats_update_on_db_open(self.inner, c_uchar::from(skip));
}
}
@ -2817,7 +2821,7 @@ impl Options {
/// ```
pub fn set_allow_mmap_writes(&mut self, is_enabled: bool) {
unsafe {
ffi::rocksdb_options_set_allow_mmap_writes(self.inner, u8::from(is_enabled));
ffi::rocksdb_options_set_allow_mmap_writes(self.inner, c_uchar::from(is_enabled));
}
}
@ -2835,7 +2839,7 @@ impl Options {
/// ```
pub fn set_allow_mmap_reads(&mut self, is_enabled: bool) {
unsafe {
ffi::rocksdb_options_set_allow_mmap_reads(self.inner, u8::from(is_enabled));
ffi::rocksdb_options_set_allow_mmap_reads(self.inner, c_uchar::from(is_enabled));
}
}
@ -2855,7 +2859,7 @@ impl Options {
/// ```
pub fn set_manual_wal_flush(&mut self, is_enabled: bool) {
unsafe {
ffi::rocksdb_options_set_manual_wal_flush(self.inner, u8::from(is_enabled));
ffi::rocksdb_options_set_manual_wal_flush(self.inner, c_uchar::from(is_enabled));
}
}
@ -2878,7 +2882,7 @@ impl Options {
/// ```
pub fn set_atomic_flush(&mut self, atomic_flush: bool) {
unsafe {
ffi::rocksdb_options_set_atomic_flush(self.inner, u8::from(atomic_flush));
ffi::rocksdb_options_set_atomic_flush(self.inner, c_uchar::from(atomic_flush));
}
}
@ -3016,7 +3020,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, u8::from(enabled));
ffi::rocksdb_options_set_dump_malloc_stats(self.inner, c_uchar::from(enabled));
}
}
@ -3031,7 +3035,7 @@ impl Options {
unsafe {
ffi::rocksdb_options_set_memtable_whole_key_filtering(
self.inner,
u8::from(whole_key_filter),
c_uchar::from(whole_key_filter),
);
}
}
@ -3153,7 +3157,7 @@ impl FlushOptions {
/// ```
pub fn set_wait(&mut self, wait: bool) {
unsafe {
ffi::rocksdb_flushoptions_set_wait(self.inner, u8::from(wait));
ffi::rocksdb_flushoptions_set_wait(self.inner, c_uchar::from(wait));
}
}
}
@ -3182,7 +3186,7 @@ impl WriteOptions {
/// Default: false
pub fn set_sync(&mut self, sync: bool) {
unsafe {
ffi::rocksdb_writeoptions_set_sync(self.inner, u8::from(sync));
ffi::rocksdb_writeoptions_set_sync(self.inner, c_uchar::from(sync));
}
}
@ -3193,7 +3197,7 @@ impl WriteOptions {
/// Default: false
pub fn disable_wal(&mut self, disable: bool) {
unsafe {
ffi::rocksdb_writeoptions_disable_WAL(self.inner, i32::from(disable));
ffi::rocksdb_writeoptions_disable_WAL(self.inner, c_int::from(disable));
}
}
@ -3206,7 +3210,7 @@ impl WriteOptions {
unsafe {
ffi::rocksdb_writeoptions_set_ignore_missing_column_families(
self.inner,
u8::from(ignore),
c_uchar::from(ignore),
);
}
}
@ -3217,7 +3221,7 @@ impl WriteOptions {
/// Default: false
pub fn set_no_slowdown(&mut self, no_slowdown: bool) {
unsafe {
ffi::rocksdb_writeoptions_set_no_slowdown(self.inner, u8::from(no_slowdown));
ffi::rocksdb_writeoptions_set_no_slowdown(self.inner, c_uchar::from(no_slowdown));
}
}
@ -3230,7 +3234,7 @@ impl WriteOptions {
/// Default: false
pub fn set_low_pri(&mut self, v: bool) {
unsafe {
ffi::rocksdb_writeoptions_set_low_pri(self.inner, u8::from(v));
ffi::rocksdb_writeoptions_set_low_pri(self.inner, c_uchar::from(v));
}
}
@ -3243,7 +3247,10 @@ 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, u8::from(v));
ffi::rocksdb_writeoptions_set_memtable_insert_hint_per_batch(
self.inner,
c_uchar::from(v),
);
}
}
}
@ -3282,7 +3289,7 @@ impl ReadOptions {
/// Default: true
pub fn fill_cache(&mut self, v: bool) {
unsafe {
ffi::rocksdb_readoptions_set_fill_cache(self.inner, u8::from(v));
ffi::rocksdb_readoptions_set_fill_cache(self.inner, c_uchar::from(v));
}
}
@ -3351,7 +3358,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, u8::from(v));
ffi::rocksdb_readoptions_set_prefix_same_as_start(self.inner, c_uchar::from(v));
}
}
@ -3364,7 +3371,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, u8::from(v));
ffi::rocksdb_readoptions_set_total_order_seek(self.inner, c_uchar::from(v));
}
}
@ -3387,7 +3394,7 @@ impl ReadOptions {
unsafe {
ffi::rocksdb_readoptions_set_background_purge_on_iterator_cleanup(
self.inner,
u8::from(v),
c_uchar::from(v),
);
}
}
@ -3399,7 +3406,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, u8::from(v));
ffi::rocksdb_readoptions_set_ignore_range_deletions(self.inner, c_uchar::from(v));
}
}
@ -3409,7 +3416,7 @@ impl ReadOptions {
/// Default: true
pub fn set_verify_checksums(&mut self, v: bool) {
unsafe {
ffi::rocksdb_readoptions_set_verify_checksums(self.inner, u8::from(v));
ffi::rocksdb_readoptions_set_verify_checksums(self.inner, c_uchar::from(v));
}
}
@ -3435,7 +3442,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, u8::from(v));
ffi::rocksdb_readoptions_set_tailing(self.inner, c_uchar::from(v));
}
}
@ -3449,7 +3456,7 @@ impl ReadOptions {
/// Default: false
pub fn set_pin_data(&mut self, v: bool) {
unsafe {
ffi::rocksdb_readoptions_set_pin_data(self.inner, u8::from(v));
ffi::rocksdb_readoptions_set_pin_data(self.inner, c_uchar::from(v));
}
}
}
@ -3470,7 +3477,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, u8::from(v));
ffi::rocksdb_ingestexternalfileoptions_set_move_files(self.inner, c_uchar::from(v));
}
}
@ -3480,7 +3487,7 @@ impl IngestExternalFileOptions {
unsafe {
ffi::rocksdb_ingestexternalfileoptions_set_snapshot_consistency(
self.inner,
u8::from(v),
c_uchar::from(v),
);
}
}
@ -3489,7 +3496,10 @@ 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, u8::from(v));
ffi::rocksdb_ingestexternalfileoptions_set_allow_global_seqno(
self.inner,
c_uchar::from(v),
);
}
}
@ -3499,7 +3509,7 @@ impl IngestExternalFileOptions {
unsafe {
ffi::rocksdb_ingestexternalfileoptions_set_allow_blocking_flush(
self.inner,
u8::from(v),
c_uchar::from(v),
);
}
}
@ -3513,7 +3523,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, u8::from(v));
ffi::rocksdb_ingestexternalfileoptions_set_ingest_behind(self.inner, c_uchar::from(v));
}
}
}
@ -3824,7 +3834,10 @@ 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, u8::from(v));
ffi::rocksdb_compactoptions_set_exclusive_manual_compaction(
self.inner,
c_uchar::from(v),
);
}
}
@ -3839,7 +3852,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, u8::from(v));
ffi::rocksdb_compactoptions_set_change_level(self.inner, c_uchar::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_void};
use libc::{c_int, c_uchar, c_void};
use crate::{ffi, ffi_util::from_cstr, Cache, Error, DB};
@ -152,7 +152,8 @@ 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, u8::from(exclude_zero_counters));
let ptr =
ffi::rocksdb_perfcontext_report(self.inner, c_uchar::from(exclude_zero_counters));
let report = from_cstr(ptr);
libc::free(ptr as *mut c_void);
report

@ -15,7 +15,7 @@
use std::ffi::CString;
use std::slice;
use libc::{c_char, c_void, size_t};
use libc::{c_char, c_uchar, c_void, size_t};
use crate::{ffi, ffi_util::CStrLike};
@ -108,9 +108,8 @@ pub unsafe extern "C" fn in_domain_callback(
raw_cb: *mut c_void,
raw_key: *const c_char,
key_len: size_t,
) -> u8 {
) -> c_uchar {
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| u8::from(in_domain(key)))
c_uchar::from(cb.in_domain_fn.map_or(true, |in_domain| in_domain(key)))
}

Loading…
Cancel
Save