Skip to content

Commit

Permalink
feat: expose set_optimize_filters_for_memory (#827)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaidoon1 committed Oct 25, 2023
1 parent bbb3fad commit a6f7a7c
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/db_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,10 @@ impl BlockBasedOptions {

/// Format version, reserved for backward compatibility.
///
/// See full [list](https://github.com/facebook/rocksdb/blob/f059c7d9b96300091e07429a60f4ad55dac84859/include/rocksdb/table.h#L249-L274)
/// See full [list](https://github.com/facebook/rocksdb/blob/v8.6.7/include/rocksdb/table.h#L493-L521)
/// of the supported versions.
///
/// Default: 2.
/// Default: 5.
pub fn set_format_version(&mut self, version: i32) {
unsafe {
ffi::rocksdb_block_based_options_set_format_version(self.inner, version);
Expand Down Expand Up @@ -642,6 +642,31 @@ impl BlockBasedOptions {
ffi::rocksdb_block_based_options_set_checksum(self.inner, checksum_type as c_char);
}
}

/// If true, generate Bloom/Ribbon filters that minimize memory internal
/// fragmentation.
/// See official [wiki](
/// https://github.com/facebook/rocksdb/wiki/RocksDB-Bloom-Filter#reducing-internal-fragmentation)
/// for more information.
///
/// Defaults to false.
/// # Examples
///
/// ```
/// use rocksdb::BlockBasedOptions;
///
/// let mut opts = BlockBasedOptions::default();
/// opts.set_bloom_filter(10.0, true);
/// opts.set_optimize_filters_for_memory(true);
/// ```
pub fn set_optimize_filters_for_memory(&mut self, v: bool) {
unsafe {
ffi::rocksdb_block_based_options_set_optimize_filters_for_memory(
self.inner,
c_uchar::from(v),
);
}
}
}

impl Default for BlockBasedOptions {
Expand Down

0 comments on commit a6f7a7c

Please sign in to comment.