Commit 714f3272 authored by siddontang's avatar siddontang Committed by GitHub

support pin l0 filter and index in cache (#32)

parent 511dd22f
......@@ -193,6 +193,8 @@ extern "C" {
pub fn crocksdb_options_set_block_based_table_factory(
options: *mut DBOptions,
block_options: *mut DBBlockBasedTableOptions);
pub fn crocksdb_block_based_options_set_pin_l0_filter_and_index_blocks_in_cache(
block_options: *mut DBBlockBasedTableOptions, v: c_uchar);
pub fn crocksdb_options_increase_parallelism(options: *mut DBOptions, threads: c_int);
pub fn crocksdb_options_optimize_level_style_compaction(options: *mut DBOptions,
memtable_memory_budget: c_int);
......
......@@ -103,6 +103,14 @@ impl BlockBasedOptions {
crocksdb_ffi::crocksdb_block_based_options_set_whole_key_filtering(self.inner, v);
}
}
pub fn set_pin_l0_filter_and_index_blocks_in_cache(&mut self, v: bool) {
unsafe {
crocksdb_ffi::crocksdb_block_based_options_set_pin_l0_filter_and_index_blocks_in_cache(
self.inner,
v as u8);
}
}
}
pub struct RateLimiter {
......
......@@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use rocksdb::{DB, Options, WriteOptions, SliceTransform};
use rocksdb::{DB, Options, BlockBasedOptions, WriteOptions, SliceTransform};
use rocksdb::crocksdb_ffi::{DBStatisticsHistogramType as HistogramType,
DBStatisticsTickerType as TickerType};
use std::path::Path;
......@@ -147,3 +147,15 @@ fn test_create_info_log() {
drop(db);
}
#[test]
fn test_set_pin_l0_filter_and_index_blocks_in_cache() {
let path = TempDir::new("_rust_rocksdb_set_cache_and_index").expect("");
let mut opts = Options::new();
opts.create_if_missing(true);
let mut block_opts = BlockBasedOptions::new();
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, path.path().to_str().unwrap()).unwrap();
drop(db);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment