Options: add set_verify_checksums and set_level_compaction_dynamic_level_bytes (#349)

master
Andronik Ordian 5 years ago committed by Oleksandr Anyshchenko
parent 473b1671c7
commit 6c7f6af7d7
  1. 10
      src/db.rs
  2. 26
      src/db_options.rs
  3. 33
      tests/test_rocksdb_options.rs

@ -1930,6 +1930,16 @@ impl ReadOptions {
unsafe { ffi::rocksdb_readoptions_set_total_order_seek(self.inner, v as c_uchar) }
}
/// If true, all data read from underlying storage will be
/// verified against corresponding checksums.
///
/// Default: true
pub fn set_verify_checksums(&mut self, v: bool) {
unsafe {
ffi::rocksdb_readoptions_set_verify_checksums(self.inner, v as c_uchar);
}
}
/// If non-zero, an iterator will create a new table reader which
/// performs reads of the given size. Using a large size (> 2MB) can
/// improve the performance of forward iteration on spinning disks.

@ -135,6 +135,21 @@ impl BlockBasedOptions {
ffi::rocksdb_block_based_options_set_index_type(self.inner, index);
}
}
/// If cache_index_and_filter_blocks is true and the below is true, then
/// filter and index blocks are stored in the cache, but a reference is
/// held in the "table reader" object so the blocks are pinned and only
/// evicted from cache when the table reader is freed.
///
/// Default: false.
pub fn set_pin_l0_filter_and_index_blocks_in_cache(&mut self, v: bool) {
unsafe {
ffi::rocksdb_block_based_options_set_pin_l0_filter_and_index_blocks_in_cache(
self.inner,
v as c_uchar,
);
}
}
}
impl Default for BlockBasedOptions {
@ -330,6 +345,17 @@ impl Options {
}
}
/// Allow RocksDB to pick dynamic base of bytes for levels.
/// With this feature turned on, RocksDB will automatically adjust max bytes for each level.
/// The goal of this feature is to have lower bound on size amplification.
///
/// 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);
}
}
pub fn set_merge_operator(
&mut self,
name: &str,

@ -15,7 +15,7 @@
extern crate rocksdb;
mod util;
use rocksdb::{Options, DB};
use rocksdb::{BlockBasedOptions, Options, ReadOptions, DB};
use util::DBPath;
#[test]
@ -39,3 +39,34 @@ fn test_increase_parallelism() {
let _db = DB::open(&opts, &n).unwrap();
}
}
#[test]
fn test_set_level_compaction_dynamic_level_bytes() {
let n = DBPath::new("_rust_rocksdb_test_set_level_compaction_dynamic_level_bytes");
{
let mut opts = Options::default();
opts.create_if_missing(true);
opts.set_level_compaction_dynamic_level_bytes(true);
let _db = DB::open(&opts, &n).unwrap();
}
}
#[test]
fn test_set_pin_l0_filter_and_index_blocks_in_cache() {
let n = DBPath::new("_rust_rocksdb_test_set_pin_l0_filter_and_index_blocks_in_cache");
{
let mut opts = Options::default();
opts.create_if_missing(true);
let mut block_opts = BlockBasedOptions::default();
block_opts.set_cache_index_and_filter_blocks(true);
block_opts.set_pin_l0_filter_and_index_blocks_in_cache(true);
opts.set_block_based_table_factory(&block_opts);
let _db = DB::open(&opts, &n).unwrap();
}
}
#[test]
fn test_read_options() {
let mut read_opts = ReadOptions::default();
read_opts.set_verify_checksums(false);
}

Loading…
Cancel
Save