From dcddc1065eae7f94c5d1bf249231f5b4cd8274e2 Mon Sep 17 00:00:00 2001 From: Hui Xiao Date: Mon, 14 Jun 2021 11:40:46 -0700 Subject: [PATCH] Make CompactionService derived from Customizable (#8395) Summary: (1)Make CompactionService derived from Customizable by defining two extra functions that are needed, as described in customizable.h comment section (2)Revise the MyTestCompactionService class in compaction_service_test.cc to satisfy the class inheritance requirement (3)Specify namespace of ToString() in compaction_service_test.cc to avoid function collision with CompactionService's ancestor classes Test did: make -j24 compaction_service_test ./compaction_service_test Pull Request resolved: https://github.com/facebook/rocksdb/pull/8395 Reviewed By: jay-zhuang Differential Revision: D29076068 Pulled By: hx235 fbshipit-source-id: c130100fa466939b3137e917f5fdc4b2ae8e37d4 --- db/compaction/compaction_service_test.cc | 10 +++++++--- include/rocksdb/options.h | 8 +++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/db/compaction/compaction_service_test.cc b/db/compaction/compaction_service_test.cc index f68b53683..1b9afab89 100644 --- a/db/compaction/compaction_service_test.cc +++ b/db/compaction/compaction_service_test.cc @@ -16,6 +16,10 @@ class MyTestCompactionService : public CompactionService { std::shared_ptr fs, Options& options) : db_path_(db_path), fs_(fs), options_(options) {} + static const char* kClassName() { return "MyTestCompactionService"; } + + const char* Name() const override { return kClassName(); } + CompactionServiceJobStatus Start(const std::string& compaction_service_input, int job_id) override { InstrumentedMutexLock l(&mutex_); @@ -51,9 +55,9 @@ class MyTestCompactionService : public CompactionService { options_override.table_factory = options_.table_factory; options_override.sst_partitioner_factory = options_.sst_partitioner_factory; - Status s = DB::OpenAndCompact(db_path_, db_path_ + "/" + ToString(job_id), - compaction_input, compaction_service_result, - options_override); + Status s = DB::OpenAndCompact( + db_path_, db_path_ + "/" + ROCKSDB_NAMESPACE::ToString(job_id), + compaction_input, compaction_service_result, options_override); TEST_SYNC_POINT_CALLBACK("MyTestCompactionService::WaitForComplete::End", compaction_service_result); compaction_num_.fetch_add(1); diff --git a/include/rocksdb/options.h b/include/rocksdb/options.h index f5f3c9363..4b46a75c2 100644 --- a/include/rocksdb/options.h +++ b/include/rocksdb/options.h @@ -20,6 +20,7 @@ #include "rocksdb/advanced_options.h" #include "rocksdb/comparator.h" #include "rocksdb/compression_type.h" +#include "rocksdb/customizable.h" #include "rocksdb/data_structure.h" #include "rocksdb/env.h" #include "rocksdb/file_checksum.h" @@ -370,8 +371,13 @@ enum class CompactionServiceJobStatus : char { kUseLocal, // TODO: Add support for use local compaction }; -class CompactionService { +class CompactionService : public Customizable { public: + static const char* Type() { return "CompactionService"; } + + // Returns the name of this compaction service. + virtual const char* Name() const = 0; + // Start the compaction with input information, which can be passed to // `DB::OpenAndCompact()`. // job_id is pre-assigned, it will be reset after DB re-open.