Commit be1f7d82 authored by yiwu-arbug's avatar yiwu-arbug Committed by Yi Wu

Pass cache as reference to BlockBasedOptions::set_block_cache (#291)

This is to get around borrow checker for TiKV side of changes. Other APIs also pass in structs as reference.
parent 76795276
...@@ -86,7 +86,7 @@ impl BlockBasedOptions { ...@@ -86,7 +86,7 @@ impl BlockBasedOptions {
} }
} }
pub fn set_block_cache(&mut self, cache: Cache) { pub fn set_block_cache(&mut self, cache: &Cache) {
unsafe { unsafe {
crocksdb_ffi::crocksdb_block_based_options_set_block_cache(self.inner, cache.inner); crocksdb_ffi::crocksdb_block_based_options_set_block_cache(self.inner, cache.inner);
} }
......
...@@ -287,7 +287,7 @@ fn test_set_lru_cache() { ...@@ -287,7 +287,7 @@ fn test_set_lru_cache() {
let mut block_opts = BlockBasedOptions::new(); let mut block_opts = BlockBasedOptions::new();
let mut cache_opts = LRUCacheOptions::new(); let mut cache_opts = LRUCacheOptions::new();
cache_opts.set_capacity(8388608); cache_opts.set_capacity(8388608);
block_opts.set_block_cache(Cache::new_lru_cache(cache_opts)); block_opts.set_block_cache(&Cache::new_lru_cache(cache_opts));
cf_opts.set_block_based_table_factory(&block_opts); cf_opts.set_block_based_table_factory(&block_opts);
DB::open_cf(opts, path.path().to_str().unwrap(), vec!["default"]).unwrap(); DB::open_cf(opts, path.path().to_str().unwrap(), vec!["default"]).unwrap();
} }
...@@ -371,7 +371,7 @@ fn test_get_block_cache_usage() { ...@@ -371,7 +371,7 @@ fn test_get_block_cache_usage() {
let mut block_opts = BlockBasedOptions::new(); let mut block_opts = BlockBasedOptions::new();
let mut cache_opts = LRUCacheOptions::new(); let mut cache_opts = LRUCacheOptions::new();
cache_opts.set_capacity(16 * 1024 * 1024); cache_opts.set_capacity(16 * 1024 * 1024);
block_opts.set_block_cache(Cache::new_lru_cache(cache_opts)); block_opts.set_block_cache(&Cache::new_lru_cache(cache_opts));
cf_opts.set_block_based_table_factory(&block_opts); cf_opts.set_block_based_table_factory(&block_opts);
let db = DB::open_cf( let db = DB::open_cf(
opts, opts,
...@@ -401,7 +401,7 @@ fn test_block_cache_capacity() { ...@@ -401,7 +401,7 @@ fn test_block_cache_capacity() {
let mut block_opts = BlockBasedOptions::new(); let mut block_opts = BlockBasedOptions::new();
let mut cache_opts = LRUCacheOptions::new(); let mut cache_opts = LRUCacheOptions::new();
cache_opts.set_capacity(16 * 1024 * 1024); cache_opts.set_capacity(16 * 1024 * 1024);
block_opts.set_block_cache(Cache::new_lru_cache(cache_opts)); block_opts.set_block_cache(&Cache::new_lru_cache(cache_opts));
cf_opts.set_block_based_table_factory(&block_opts); cf_opts.set_block_based_table_factory(&block_opts);
let db = DB::open_cf( let db = DB::open_cf(
opts, opts,
......
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