From 83d1a665988f3cf892df978fdf8d74b7e2bee08c Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Mon, 17 May 2021 22:52:05 -0700 Subject: [PATCH] Expose CompressionOptions::parallel_threads through C API (#8302) Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/8302 Reviewed By: jay-zhuang Differential Revision: D28499262 Pulled By: ajkr fbshipit-source-id: 7b17b79af871d874dfca76db9bca0d640a6cd854 --- db/c.cc | 20 ++++++++++++++++++++ db/c_test.c | 22 ++++++++++++++++++++++ include/rocksdb/c.h | 12 ++++++++++++ 3 files changed, 54 insertions(+) diff --git a/db/c.cc b/db/c.cc index 64ff26646..79fa5181d 100644 --- a/db/c.cc +++ b/db/c.cc @@ -2864,11 +2864,31 @@ void rocksdb_options_set_compression_options_zstd_max_train_bytes( opt->rep.compression_opts.zstd_max_train_bytes = zstd_max_train_bytes; } +int rocksdb_options_get_compression_options_zstd_max_train_bytes( + rocksdb_options_t* opt) { + return opt->rep.compression_opts.zstd_max_train_bytes; +} + +void rocksdb_options_set_compression_options_parallel_threads( + rocksdb_options_t* opt, int value) { + opt->rep.compression_opts.parallel_threads = value; +} + +int rocksdb_options_get_compression_options_parallel_threads( + rocksdb_options_t* opt) { + return opt->rep.compression_opts.parallel_threads; +} + void rocksdb_options_set_compression_options_max_dict_buffer_bytes( rocksdb_options_t* opt, uint64_t max_dict_buffer_bytes) { opt->rep.compression_opts.max_dict_buffer_bytes = max_dict_buffer_bytes; } +uint64_t rocksdb_options_get_compression_options_max_dict_buffer_bytes( + rocksdb_options_t* opt) { + return opt->rep.compression_opts.max_dict_buffer_bytes; +} + void rocksdb_options_set_prefix_extractor( rocksdb_options_t* opt, rocksdb_slicetransform_t* prefix_extractor) { opt->rep.prefix_extractor.reset(prefix_extractor); diff --git a/db/c_test.c b/db/c_test.c index e836b1509..5b7459b06 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -2539,6 +2539,28 @@ int main(int argc, char** argv) { rocksdb_backupable_db_options_destroy(bdo); } + StartPhase("compression_options"); + { + rocksdb_options_t* co; + co = rocksdb_options_create(); + + rocksdb_options_set_compression_options_zstd_max_train_bytes(co, 100); + CheckCondition( + 100 == + rocksdb_options_get_compression_options_zstd_max_train_bytes(co)); + + rocksdb_options_set_compression_options_parallel_threads(co, 2); + CheckCondition( + 2 == rocksdb_options_get_compression_options_parallel_threads(co)); + + rocksdb_options_set_compression_options_max_dict_buffer_bytes(co, 200); + CheckCondition( + 200 == + rocksdb_options_get_compression_options_max_dict_buffer_bytes(co)); + + rocksdb_options_destroy(co); + } + StartPhase("iterate_upper_bound"); { // Create new empty database diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index 1b19be2c4..8280b25a2 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -1004,9 +1004,21 @@ extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compression_options( extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compression_options_zstd_max_train_bytes(rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int +rocksdb_options_get_compression_options_zstd_max_train_bytes( + rocksdb_options_t* opt); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_compression_options_parallel_threads(rocksdb_options_t*, + int); +extern ROCKSDB_LIBRARY_API int +rocksdb_options_get_compression_options_parallel_threads( + rocksdb_options_t* opt); extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compression_options_max_dict_buffer_bytes( rocksdb_options_t*, uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_compression_options_max_dict_buffer_bytes( + rocksdb_options_t* opt); extern ROCKSDB_LIBRARY_API void rocksdb_options_set_bottommost_compression_options(rocksdb_options_t*, int, int, int, int, unsigned char);