diff --git a/CHANGELOG.md b/CHANGELOG.md index 3066886..c3c0652 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## [Unreleased] * Bump `librocksdb-sys` up to 6.19.3 (olegnn) +* Add `DB::key_may_exist_cf_opt` method (stanislav-tkach) +* Add `Options::set_zstd_max_train_bytes` method (stanislav-tkach) ## 0.16.0 (2021-04-18) @@ -17,13 +19,13 @@ * Bump `librocksdb-sys` up to 6.17.3 (ordian) * Remove the need for `&mut self` in `create_cf` and `drop_cf` (v2) (ryoqun) * Keep Cache and Env alive with Rc (acrrd) -* Add DB::open_cf_with_ttl method (fdeantoni) +* Add `DB::open_cf_with_ttl` method (fdeantoni) ## 0.15.0 (2020-08-25) * Fix building rocksdb library on windows host (aleksuss) * Add github actions CI for windows build (aleksuss) -* Update doc for Options::set_compression_type (wqfish) +* Update doc for `Options::set_compression_type` (wqfish) * Add clippy linter in CI (aleksuss) * Use DBPath for backup_restore test (wqfish) * Allow to build RocksDB with a different stdlib (calavera) diff --git a/src/db_options.rs b/src/db_options.rs index 81c3d7e..7e42f8f 100644 --- a/src/db_options.rs +++ b/src/db_options.rs @@ -1051,6 +1051,19 @@ impl Options { } } + /// Sets maximum size of training data passed to zstd's dictionary trainer. Using zstd's + /// dictionary trainer can achieve even better compression ratio improvements than using + /// `max_dict_bytes` alone. + /// + /// The training data will be used to generate a dictionary of max_dict_bytes. + /// + /// Default: 0. + pub fn set_zstd_max_train_bytes(&mut self, value: c_int) { + unsafe { + ffi::rocksdb_options_set_compression_options_zstd_max_train_bytes(self.inner, value); + } + } + /// If non-zero, we perform bigger reads when doing compaction. If you're /// running RocksDB on spinning disks, you should set this to at least 2MB. /// That way RocksDB's compaction is doing sequential instead of random reads. diff --git a/tests/test_db.rs b/tests/test_db.rs index b5947af..6d70ffd 100644 --- a/tests/test_db.rs +++ b/tests/test_db.rs @@ -974,7 +974,7 @@ fn multi_get_cf() { #[test] fn key_may_exist() { - let path = DBPath::new("_rust_rocksdb_multi_get"); + let path = DBPath::new("_rust_key_may_exist"); { let db = DB::open_default(&path).unwrap(); @@ -988,7 +988,7 @@ fn key_may_exist() { #[test] fn key_may_exist_cf() { - let path = DBPath::new("_rust_rocksdb_multi_get_cf"); + let path = DBPath::new("_rust_key_may_exist_cf"); { let mut opts = Options::default(); diff --git a/tests/test_rocksdb_options.rs b/tests/test_rocksdb_options.rs index 8089b3d..cb1b3d7 100644 --- a/tests/test_rocksdb_options.rs +++ b/tests/test_rocksdb_options.rs @@ -134,3 +134,15 @@ fn test_set_data_block_index_type() { assert!(settings.contains("data_block_hash_table_util_ratio: 0.350000")); } } + +#[test] +fn set_compression_options_zstd_max_train_bytes() { + let path = DBPath::new("_rust_set_compression_options_zstd_max_train_bytes"); + { + let mut opts = Options::default(); + opts.create_if_missing(true); + opts.set_compression_options(4, 5, 6, 7); + opts.set_zstd_max_train_bytes(100); + let _db = DB::open(&opts, &path).unwrap(); + } +}