From 9d16f0ff9f1c152cd3a5a1a70ae9cc4c70dbb65f Mon Sep 17 00:00:00 2001 From: zaidoon Date: Thu, 21 Dec 2023 03:08:42 -0500 Subject: [PATCH] Expose Options::ttl through C API --- db/c.cc | 8 ++++++++ db/c_test.c | 7 +++++++ include/rocksdb/c.h | 3 +++ .../public_api_changes/expose_options_ttl_via_c_api.md | 1 + 4 files changed, 19 insertions(+) create mode 100644 unreleased_history/public_api_changes/expose_options_ttl_via_c_api.md diff --git a/db/c.cc b/db/c.cc index 5555ae19875..1e9ca581db6 100644 --- a/db/c.cc +++ b/db/c.cc @@ -3049,6 +3049,14 @@ void rocksdb_options_set_max_bytes_for_level_multiplier_additional( } } +void rocksdb_options_set_ttl(rocksdb_options_t* opt, uint64_t seconds) { + opt->rep.ttl = seconds; +} + +uint64_t rocksdb_options_get_ttl(rocksdb_options_t* opt) { + return opt->rep.ttl; +} + void rocksdb_options_set_periodic_compaction_seconds(rocksdb_options_t* opt, uint64_t seconds) { opt->rep.periodic_compaction_seconds = seconds; diff --git a/db/c_test.c b/db/c_test.c index 66722049692..e3b79f0c4a7 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -1925,6 +1925,9 @@ int main(int argc, char** argv) { CheckCondition(100000 == rocksdb_options_get_periodic_compaction_seconds(o)); + rocksdb_options_set_ttl(o, 5000); + CheckCondition(5000 == rocksdb_options_get_ttl(o)); + rocksdb_options_set_skip_stats_update_on_db_open(o, 1); CheckCondition(1 == rocksdb_options_get_skip_stats_update_on_db_open(o)); @@ -2361,6 +2364,10 @@ int main(int argc, char** argv) { CheckCondition(100000 == rocksdb_options_get_periodic_compaction_seconds(o)); + rocksdb_options_set_ttl(copy, 8000); + CheckCondition(8000 == rocksdb_options_get_ttl(copy)); + CheckCondition(5000 == rocksdb_options_get_ttl(o)); + rocksdb_options_set_skip_stats_update_on_db_open(copy, 0); CheckCondition(0 == rocksdb_options_get_skip_stats_update_on_db_open(copy)); CheckCondition(1 == rocksdb_options_get_skip_stats_update_on_db_open(o)); diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index 8a26585fe73..54c770a6fa1 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -1261,6 +1261,9 @@ rocksdb_options_set_max_bytes_for_level_multiplier_additional( rocksdb_options_t*, int* level_values, size_t num_levels); extern ROCKSDB_LIBRARY_API void rocksdb_options_enable_statistics( rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_ttl(rocksdb_options_t*, + uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t rocksdb_options_get_ttl(rocksdb_options_t*); extern ROCKSDB_LIBRARY_API void rocksdb_options_set_periodic_compaction_seconds( rocksdb_options_t*, uint64_t); extern ROCKSDB_LIBRARY_API uint64_t diff --git a/unreleased_history/public_api_changes/expose_options_ttl_via_c_api.md b/unreleased_history/public_api_changes/expose_options_ttl_via_c_api.md new file mode 100644 index 00000000000..5576f93b3c2 --- /dev/null +++ b/unreleased_history/public_api_changes/expose_options_ttl_via_c_api.md @@ -0,0 +1 @@ +Exposed options ttl via c api. \ No newline at end of file