|
|
@ -106,14 +106,12 @@ impl OptionsMustOutliveDB { |
|
|
|
#[derive(Default)] |
|
|
|
#[derive(Default)] |
|
|
|
struct BlockBasedOptionsMustOutliveDB { |
|
|
|
struct BlockBasedOptionsMustOutliveDB { |
|
|
|
block_cache: Option<Cache>, |
|
|
|
block_cache: Option<Cache>, |
|
|
|
block_cache_compressed: Option<Cache>, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl BlockBasedOptionsMustOutliveDB { |
|
|
|
impl BlockBasedOptionsMustOutliveDB { |
|
|
|
fn clone(&self) -> Self { |
|
|
|
fn clone(&self) -> Self { |
|
|
|
Self { |
|
|
|
Self { |
|
|
|
block_cache: self.block_cache.as_ref().map(Cache::clone), |
|
|
|
block_cache: self.block_cache.as_ref().map(Cache::clone), |
|
|
|
block_cache_compressed: self.block_cache_compressed.as_ref().map(Cache::clone), |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -393,24 +391,6 @@ impl BlockBasedOptions { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// When configured: use the specified cache for compressed blocks.
|
|
|
|
|
|
|
|
/// Otherwise rocksdb will not use a compressed block cache.
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// Note: though it looks similar to `block_cache`, RocksDB doesn't put the
|
|
|
|
|
|
|
|
/// same type of object there.
|
|
|
|
|
|
|
|
#[deprecated(
|
|
|
|
|
|
|
|
since = "0.15.0", |
|
|
|
|
|
|
|
note = "This function will be removed in next release. Use set_block_cache_compressed instead" |
|
|
|
|
|
|
|
)] |
|
|
|
|
|
|
|
pub fn set_lru_cache_compressed(&mut self, size: size_t) { |
|
|
|
|
|
|
|
let cache = new_cache(size); |
|
|
|
|
|
|
|
unsafe { |
|
|
|
|
|
|
|
// Since cache is wrapped in shared_ptr, we don't need to
|
|
|
|
|
|
|
|
// call rocksdb_cache_destroy explicitly.
|
|
|
|
|
|
|
|
ffi::rocksdb_block_based_options_set_block_cache_compressed(self.inner, cache); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Sets global cache for blocks (user data is stored in a set of blocks, and
|
|
|
|
/// Sets global cache for blocks (user data is stored in a set of blocks, and
|
|
|
|
/// a block is the unit of reading from disk). Cache must outlive DB instance which uses it.
|
|
|
|
/// a block is the unit of reading from disk). Cache must outlive DB instance which uses it.
|
|
|
|
///
|
|
|
|
///
|
|
|
@ -423,16 +403,6 @@ impl BlockBasedOptions { |
|
|
|
self.outlive.block_cache = Some(cache.clone()); |
|
|
|
self.outlive.block_cache = Some(cache.clone()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Sets global cache for compressed blocks. Cache must outlive DB instance which uses it.
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// By default, rocksdb will not use a compressed block cache.
|
|
|
|
|
|
|
|
pub fn set_block_cache_compressed(&mut self, cache: &Cache) { |
|
|
|
|
|
|
|
unsafe { |
|
|
|
|
|
|
|
ffi::rocksdb_block_based_options_set_block_cache_compressed(self.inner, cache.0.inner); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
self.outlive.block_cache_compressed = Some(cache.clone()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Disable block cache
|
|
|
|
/// Disable block cache
|
|
|
|
pub fn disable_cache(&mut self) { |
|
|
|
pub fn disable_cache(&mut self) { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|