Skip to content

Commit

Permalink
Make CompactionService derived from Customizable (facebook#8395)
Browse files Browse the repository at this point in the history
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: facebook#8395

Reviewed By: jay-zhuang

Differential Revision: D29076068

Pulled By: hx235

fbshipit-source-id: c130100fa466939b3137e917f5fdc4b2ae8e37d4
  • Loading branch information
hx235 authored and facebook-github-bot committed Jun 14, 2021
1 parent 9047fd7 commit dcddc10
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 7 additions & 3 deletions db/compaction/compaction_service_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class MyTestCompactionService : public CompactionService {
std::shared_ptr<FileSystem> 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_);
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion include/rocksdb/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit dcddc10

Please sign in to comment.