-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for Customizable DB Open Hooks for DB Bench
Summary: This diff introduces ToolHooks, a class which allows for users to interpose their own set of logic for various functionality with db_bench_tool (i.e., various OpenDB implementations). Differential Revision: D67868126
- Loading branch information
1 parent
0e469c7
commit ef48623
Showing
6 changed files
with
230 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved. | ||
// This source code is licensed under both the GPLv2 (found in the | ||
// COPYING file in the root directory) and Apache 2.0 License | ||
// (found in the LICENSE.Apache file in the root directory). | ||
// 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. | ||
|
||
#pragma once | ||
|
||
#include "rocksdb/db.h" | ||
|
||
|
||
namespace ROCKSDB_NAMESPACE { | ||
|
||
struct TransactionDBOptions; | ||
class TransactionDB; | ||
class OptimisticTransactionDB; | ||
|
||
namespace blob_db { | ||
struct BlobDBOptions; | ||
class BlobDB; | ||
} | ||
|
||
/* | ||
* ToolHooks is currently a WORK IN PROGRESS, API is subject to change. | ||
* ToolHooks is a class that allows users to override the default behavior of the various OpenDB calls used by | ||
* db_bench_tool. This allows users to easily extend the functionality of db_bench_tool to support their own | ||
* open implementations. | ||
*/ | ||
class ToolHooks { | ||
public: | ||
ToolHooks() = default; | ||
virtual ~ToolHooks() = default; | ||
virtual Status Open(const Options& db_options, const std::string& name, DB** dbptr) = 0; | ||
virtual Status Open(const DBOptions& db_options, const std::string& name, | ||
const std::vector<ColumnFamilyDescriptor>& column_families, | ||
std::vector<ColumnFamilyHandle*>* handles, DB** dbptr) = 0; | ||
virtual Status OpenForReadOnly(const Options& options, const std::string& name, | ||
DB** dbptr, | ||
bool error_if_wal_file_exists) = 0; | ||
virtual Status OpenForReadOnly(const Options& options, const std::string& name, | ||
const std::vector<ColumnFamilyDescriptor>& column_families, | ||
std::vector<ColumnFamilyHandle*>* handles, DB** dbptr) = 0; | ||
virtual Status OpenTransactionDB(const Options& db_options, | ||
const TransactionDBOptions& txn_db_options, | ||
const std::string& dbname, | ||
TransactionDB** dbptr) = 0; | ||
virtual Status OpenTransactionDB(const DBOptions& db_options, | ||
const TransactionDBOptions& txn_db_options, | ||
const std::string& dbname, | ||
const std::vector<ColumnFamilyDescriptor>& column_families, | ||
std::vector<ColumnFamilyHandle*>* handles, | ||
TransactionDB** dbptr) = 0; | ||
virtual Status OpenOptimisticTransactionDB(const Options& options, const std::string& dbname, | ||
OptimisticTransactionDB** dbptr) = 0; | ||
virtual Status OpenOptimisticTransactionDB(const DBOptions& db_options, const std::string& dbname, | ||
const std::vector<ColumnFamilyDescriptor>& column_families, | ||
std::vector<ColumnFamilyHandle*>* handles, | ||
OptimisticTransactionDB** dbptr) = 0; | ||
virtual Status OpenAsSecondary(const Options& options, const std::string& name, | ||
const std::string& secondary_path, DB** dbptr) = 0; | ||
virtual Status OpenAsFollower(const Options& options, const std::string& name, | ||
const std::string& leader_path, | ||
std::unique_ptr<DB>* dbptr) = 0; | ||
virtual Status Open(const Options& options, const blob_db::BlobDBOptions& bdb_options, | ||
const std::string& dbname, blob_db::BlobDB** blob_db) = 0; | ||
|
||
}; | ||
|
||
class DefaultHooks : public ToolHooks { | ||
public: | ||
DefaultHooks() = default; | ||
~DefaultHooks() override = default; | ||
virtual Status Open(const Options& db_options, const std::string& name, DB** dbptr) override; | ||
virtual Status Open(const DBOptions& db_options, const std::string& name, | ||
const std::vector<ColumnFamilyDescriptor>& column_families, | ||
std::vector<ColumnFamilyHandle*>* handles, DB** dbptr) override; | ||
virtual Status OpenForReadOnly(const Options& options, const std::string& name, | ||
DB** dbptr, | ||
bool error_if_wal_file_exists) override; | ||
virtual Status OpenForReadOnly(const Options& options, const std::string& name, | ||
const std::vector<ColumnFamilyDescriptor>& column_families, | ||
std::vector<ColumnFamilyHandle*>* handles, DB** dbptr) override; | ||
virtual Status OpenTransactionDB(const Options& db_options, | ||
const TransactionDBOptions& txn_db_options, | ||
const std::string& dbname, | ||
TransactionDB** dbptr) override; | ||
virtual Status OpenTransactionDB(const DBOptions& db_options, | ||
const TransactionDBOptions& txn_db_options, | ||
const std::string& dbname, | ||
const std::vector<ColumnFamilyDescriptor>& column_families, | ||
std::vector<ColumnFamilyHandle*>* handles, | ||
TransactionDB** dbptr) override; | ||
virtual Status OpenOptimisticTransactionDB(const Options& options, const std::string& dbname, | ||
OptimisticTransactionDB** dbptr) override; | ||
virtual Status OpenOptimisticTransactionDB(const DBOptions& db_options, const std::string& dbname, | ||
const std::vector<ColumnFamilyDescriptor>& column_families, | ||
std::vector<ColumnFamilyHandle*>* handles, | ||
OptimisticTransactionDB** dbptr) override; | ||
virtual Status OpenAsSecondary(const Options& options, const std::string& name, | ||
const std::string& secondary_path, DB** dbptr) override; | ||
virtual Status OpenAsFollower(const Options& options, const std::string& name, | ||
const std::string& leader_path, | ||
std::unique_ptr<DB>* dbptr) override; | ||
virtual Status Open(const Options& options, const blob_db::BlobDBOptions& bdb_options, | ||
const std::string& dbname, blob_db::BlobDB** blob_db) override; | ||
}; | ||
|
||
extern DefaultHooks defaultHooks; | ||
|
||
} // namespace ROCKSDB_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.