|
|
@ -14,6 +14,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
use std::ffi::{CStr, CString}; |
|
|
|
use std::ffi::{CStr, CString}; |
|
|
|
use std::mem; |
|
|
|
use std::mem; |
|
|
|
|
|
|
|
use std::path::Path; |
|
|
|
|
|
|
|
|
|
|
|
use libc::{self, c_int, c_uchar, c_uint, c_void, size_t, uint64_t}; |
|
|
|
use libc::{self, c_int, c_uchar, c_uint, c_void, size_t, uint64_t}; |
|
|
|
|
|
|
|
|
|
|
@ -72,6 +73,12 @@ impl BlockBasedOptions { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn disable_cache(&mut self) { |
|
|
|
|
|
|
|
unsafe { |
|
|
|
|
|
|
|
ffi::rocksdb_block_based_options_set_no_block_cache(self.inner, true as c_uchar); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn set_bloom_filter(&mut self, bits_per_key: c_int, block_based: bool) { |
|
|
|
pub fn set_bloom_filter(&mut self, bits_per_key: c_int, block_based: bool) { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
let bloom = if block_based { |
|
|
|
let bloom = if block_based { |
|
|
@ -221,6 +228,20 @@ impl Options { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// If non-zero, we perform bigger reads when doing compaction. If you're
|
|
|
|
|
|
|
|
/// running RocksDB on spinning disks, you should set this to at least 2MB.
|
|
|
|
|
|
|
|
/// That way RocksDB's compaction is doing sequential instead of random reads.
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// When non-zero, we also force new_table_reader_for_compaction_inputs to
|
|
|
|
|
|
|
|
/// true.
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// 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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn set_merge_operator(&mut self, name: &str, |
|
|
|
pub fn set_merge_operator(&mut self, name: &str, |
|
|
|
full_merge_fn: MergeFn, |
|
|
|
full_merge_fn: MergeFn, |
|
|
|
partial_merge_fn: Option<MergeFn>) { |
|
|
|
partial_merge_fn: Option<MergeFn>) { |
|
|
@ -986,10 +1007,6 @@ impl Options { |
|
|
|
/// `write_buffer_size * memtable_prefix_bloom_ratio` (capped at 0.25).
|
|
|
|
/// `write_buffer_size * memtable_prefix_bloom_ratio` (capped at 0.25).
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// Default: `0`
|
|
|
|
/// Default: `0`
|
|
|
|
///
|
|
|
|
|
|
|
|
/// # Example
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
|
|
|
|
/// use rocksdb::{Options, SliceTransform};
|
|
|
|
/// use rocksdb::{Options, SliceTransform};
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// let mut opts = Options::default();
|
|
|
|
/// let mut opts = Options::default();
|
|
|
@ -1002,6 +1019,26 @@ impl Options { |
|
|
|
ffi::rocksdb_options_set_memtable_prefix_bloom_size_ratio(self.inner, ratio); |
|
|
|
ffi::rocksdb_options_set_memtable_prefix_bloom_size_ratio(self.inner, ratio); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Specifies the absolute path of the directory the
|
|
|
|
|
|
|
|
/// write-ahead log (WAL) should be written to.
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// Default: same directory as the database
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// # Example
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
|
|
|
|
/// use rocksdb::Options;
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// let mut opts = Options::default();
|
|
|
|
|
|
|
|
/// opts.set_wal_dir("/path/to/dir");
|
|
|
|
|
|
|
|
/// ```
|
|
|
|
|
|
|
|
pub fn set_wal_dir<P: AsRef<Path>>(&mut self, path: P) { |
|
|
|
|
|
|
|
let p = CString::new(path.as_ref().to_string_lossy().as_bytes()).unwrap(); |
|
|
|
|
|
|
|
unsafe { |
|
|
|
|
|
|
|
ffi::rocksdb_options_set_wal_dir(self.inner, p.as_ptr()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl Default for Options { |
|
|
|
impl Default for Options { |
|
|
|