From 1f410ff95f623216c6d1c72f8d0788ed333e829c Mon Sep 17 00:00:00 2001 From: Changyu Bi Date: Fri, 7 Jul 2023 13:16:20 -0700 Subject: [PATCH] Make `rocksdb_options_add_compact_on_deletion_collector_factory` backward compatible (#11593) Summary: https://github.com/facebook/rocksdb/issues/11542 added a parameter to the C API `rocksdb_options_add_compact_on_deletion_collector_factory` which causes some internal builds to fail. External users using this API would also require code change. Making the API backward compatible by restoring the old C API and add the parameter to a new C API `rocksdb_options_add_compact_on_deletion_collector_factory_del_ratio`. Also updated change log for 8.4 and will backport this change to 8.4 branch once landed. Pull Request resolved: https://github.com/facebook/rocksdb/pull/11593 Test Plan: `make c_test && ./c_test` Reviewed By: akankshamahajan15 Differential Revision: D47299555 Pulled By: cbi42 fbshipit-source-id: 517dc093ef4cf02cac2fe4af4f1af13754bbda63 --- HISTORY.md | 2 +- db/c.cc | 8 ++++++++ db/c_test.c | 4 +++- include/rocksdb/c.h | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 91f28f3e2..f4dce5cd8 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -14,7 +14,7 @@ * Add `WriteBatch::Release()` that releases the batch's serialized data to the caller. ### Public API Changes -* Add parameter `deletion_ratio` to C API `rocksdb_options_add_compact_on_deletion_collector_factory`. +* Add C API `rocksdb_options_add_compact_on_deletion_collector_factory_del_ratio`. * change the FileSystem::use_async_io() API to SupportedOps API in order to extend it to various operations supported by underlying FileSystem. Right now it contains FSSupportedOps::kAsyncIO and FSSupportedOps::kFSBuffer. More details about FSSupportedOps in filesystem.h * Add new tickers: `rocksdb.error.handler.bg.error.count`, `rocksdb.error.handler.bg.io.error.count`, `rocksdb.error.handler.bg.retryable.io.error.count` to replace the misspelled ones: `rocksdb.error.handler.bg.errro.count`, `rocksdb.error.handler.bg.io.errro.count`, `rocksdb.error.handler.bg.retryable.io.errro.count` ('error' instead of 'errro'). Users should switch to use the new tickers before 9.0 release as the misspelled old tickers will be completely removed then. * Overload the API CreateColumnFamilyWithImport() to support creating ColumnFamily by importing multiple ColumnFamilies It requires that CFs should not overlap in user key range. diff --git a/db/c.cc b/db/c.cc index 88527f99c..6da280b46 100644 --- a/db/c.cc +++ b/db/c.cc @@ -3916,6 +3916,14 @@ void rocksdb_options_set_row_cache(rocksdb_options_t* opt, } void rocksdb_options_add_compact_on_deletion_collector_factory( + rocksdb_options_t* opt, size_t window_size, size_t num_dels_trigger) { + std::shared_ptr + compact_on_del = + NewCompactOnDeletionCollectorFactory(window_size, num_dels_trigger); + opt->rep.table_properties_collector_factories.emplace_back(compact_on_del); +} + +void rocksdb_options_add_compact_on_deletion_collector_factory_del_ratio( rocksdb_options_t* opt, size_t window_size, size_t num_dels_trigger, double deletion_ratio) { std::shared_ptr diff --git a/db/c_test.c b/db/c_test.c index 454aa1622..a694643bc 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -720,7 +720,9 @@ int main(int argc, char** argv) { rocksdb_compactoptions_set_exclusive_manual_compaction(coptions, 1); rocksdb_options_add_compact_on_deletion_collector_factory(options, 10000, - 10001, 0.0); + 10001); + rocksdb_options_add_compact_on_deletion_collector_factory_del_ratio( + options, 10000, 10001, 0.0); StartPhase("destroy"); rocksdb_destroy_db(options, dbname, &err); diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index 808617db6..81d05f778 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -1626,6 +1626,9 @@ extern ROCKSDB_LIBRARY_API void rocksdb_options_set_row_cache( extern ROCKSDB_LIBRARY_API void rocksdb_options_add_compact_on_deletion_collector_factory( + rocksdb_options_t*, size_t window_size, size_t num_dels_trigger); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_add_compact_on_deletion_collector_factory_del_ratio( rocksdb_options_t*, size_t window_size, size_t num_dels_trigger, double deletion_ratio); extern ROCKSDB_LIBRARY_API void rocksdb_options_set_manual_wal_flush(