From 11509044d3ae6e39a2f6f7d401a0f3d2c5f72c20 Mon Sep 17 00:00:00 2001 From: Jurriaan Mous Date: Mon, 6 Jan 2025 21:37:28 +0100 Subject: [PATCH] Add additional methods to C api for compactoptions --- db/c.cc | 29 +++++++++++++++++++++++++++++ db/c_test.c | 9 +++++++++ include/rocksdb/c.h | 12 ++++++++++++ 3 files changed, 50 insertions(+) diff --git a/db/c.cc b/db/c.cc index 77b0a6af326..4f7c95f0c10 100644 --- a/db/c.cc +++ b/db/c.cc @@ -5000,6 +5000,35 @@ int rocksdb_compactoptions_get_target_level(rocksdb_compactoptions_t* opt) { return opt->rep.target_level; } +void rocksdb_compactoptions_set_target_path_id(rocksdb_compactoptions_t* opt, + int n) { + opt->rep.target_path_id = n; +} + +int rocksdb_compactoptions_get_target_path_id(rocksdb_compactoptions_t* opt) { + return opt->rep.target_path_id; +} + +void rocksdb_compactoptions_set_allow_write_stall(rocksdb_compactoptions_t* opt, + unsigned char v) { + opt->rep.allow_write_stall = v; +} + +unsigned char rocksdb_compactoptions_get_allow_write_stall( + rocksdb_compactoptions_t* opt) { + return opt->rep.allow_write_stall; +} + +void rocksdb_compactoptions_set_max_subcompactions( + rocksdb_compactoptions_t* opt, int n) { + opt->rep.max_subcompactions = n; +} + +int rocksdb_compactoptions_get_max_subcompactions( + rocksdb_compactoptions_t* opt) { + return opt->rep.max_subcompactions; +} + void rocksdb_compactoptions_set_full_history_ts_low( rocksdb_compactoptions_t* opt, char* ts, size_t tslen) { if (ts == nullptr) { diff --git a/db/c_test.c b/db/c_test.c index eb9886ba467..18bf2961ded 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -2938,6 +2938,15 @@ int main(int argc, char** argv) { rocksdb_compactoptions_set_target_level(co, 1); CheckCondition(1 == rocksdb_compactoptions_get_target_level(co)); + rocksdb_compactoptions_set_target_path_id(co, 1); + CheckCondition(1 == rocksdb_compactoptions_get_target_path_id(co)); + + rocksdb_compactoptions_set_allow_write_stall(co, 1); + CheckCondition(1 == rocksdb_compactoptions_get_allow_write_stall(co)); + + rocksdb_compactoptions_set_max_subcompactions(co, 1); + CheckCondition(1 == rocksdb_compactoptions_get_max_subcompactions(co)); + rocksdb_compactoptions_destroy(co); } diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index ff452a3546e..59ea873e57e 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -2129,6 +2129,18 @@ extern ROCKSDB_LIBRARY_API void rocksdb_compactoptions_set_target_level( rocksdb_compactoptions_t*, int); extern ROCKSDB_LIBRARY_API int rocksdb_compactoptions_get_target_level( rocksdb_compactoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_compactoptions_set_target_path_id( + rocksdb_compactoptions_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_compactoptions_get_target_path_id( + rocksdb_compactoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_compactoptions_set_allow_write_stall( + rocksdb_compactoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_compactoptions_get_allow_write_stall(rocksdb_compactoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_compactoptions_set_max_subcompactions( + rocksdb_compactoptions_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_compactoptions_get_max_subcompactions( + rocksdb_compactoptions_t*); extern ROCKSDB_LIBRARY_API void rocksdb_compactoptions_set_full_history_ts_low( rocksdb_compactoptions_t*, char* ts, size_t tslen);