From fd26f315ae0776865cd38228caa39eb8e04cbb25 Mon Sep 17 00:00:00 2001 From: zaidoon Date: Fri, 3 Nov 2023 01:08:40 -0400 Subject: [PATCH 1/2] Expose Options::periodic_compaction_seconds via C API --- db/c.cc | 10 ++++++++++ db/c_test.c | 24 ++++++++++++++++++++++++ include/rocksdb/c.h | 4 ++++ 3 files changed, 38 insertions(+) diff --git a/db/c.cc b/db/c.cc index c8a0380237..286c86b7eb 100644 --- a/db/c.cc +++ b/db/c.cc @@ -3003,6 +3003,16 @@ void rocksdb_options_set_max_bytes_for_level_multiplier_additional( } } +void rocksdb_options_set_periodic_compaction_seconds(rocksdb_options_t* opt, + uint64_t seconds) { + opt->rep.periodic_compaction_seconds = seconds; +} + +uint64_t rocksdb_options_get_periodic_compaction_seconds( + rocksdb_options_t* opt) { + return opt->rep.periodic_compaction_seconds; +} + void rocksdb_options_enable_statistics(rocksdb_options_t* opt) { opt->rep.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics(); } diff --git a/db/c_test.c b/db/c_test.c index a1e1991020..05bbb71710 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -1,3 +1,17 @@ +// Copyright (C) 2023 Speedb Ltd. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + /* Copyright (c) 2011 The LevelDB Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. See the AUTHORS file for names of contributors. */ @@ -1839,6 +1853,10 @@ int main(int argc, char** argv) { CheckCondition(2.0 == rocksdb_options_get_max_bytes_for_level_multiplier(o)); + rocksdb_options_set_periodic_compaction_seconds(o, 100000); + CheckCondition(100000 == + rocksdb_options_get_periodic_compaction_seconds(o)); + rocksdb_options_set_skip_stats_update_on_db_open(o, 1); CheckCondition(1 == rocksdb_options_get_skip_stats_update_on_db_open(o)); @@ -2260,6 +2278,12 @@ int main(int argc, char** argv) { CheckCondition(2.0 == rocksdb_options_get_max_bytes_for_level_multiplier(o)); + rocksdb_options_set_periodic_compaction_seconds(copy, 8000); + CheckCondition(8000 == + rocksdb_options_get_periodic_compaction_seconds(copy)); + CheckCondition(100000 == + rocksdb_options_get_periodic_compaction_seconds(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 fc4f6cfeb4..b552533471 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -1268,6 +1268,10 @@ rocksdb_options_set_skip_checking_sst_file_sizes_on_db_open( extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_skip_checking_sst_file_sizes_on_db_open( rocksdb_options_t* opt); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_periodic_compaction_seconds( + rocksdb_options_t*, uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_periodic_compaction_seconds(rocksdb_options_t*); /* Blob Options Settings */ extern ROCKSDB_LIBRARY_API void rocksdb_options_set_enable_blob_files( From 4c5161356e957b5edc5088a53c44582b07b3c665 Mon Sep 17 00:00:00 2001 From: zaidoon Date: Wed, 8 Nov 2023 03:19:43 -0500 Subject: [PATCH 2/2] update HISTORY --- HISTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/HISTORY.md b/HISTORY.md index 925ad1a03e..c3dbf81631 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -18,6 +18,7 @@ * Added a kUseBaseAddress flag and GetBaseOffset flag to OptionTypeInfo. If this flag is set and a function is used for processing options, the function is passed the base address of the struct rather than the specific field (#397) * Static Pinning: Set the default for mid-percent capacity threshold in scoped pinning policy to 70 (#689). * db_bench: Add support for individual scoped pinning policy parameters (#687). +* Expose Options::periodic_compaction_seconds via C API (#741). ### Bug Fixes * db_bench: Fix SeekRandomWriteRandom valid check. Use key and value only after checking iterator is valid.