Replace the namespace "rocksdb" to "ROCKSDB_NAMESPACE" (#8531)

Summary:
For more detail can reference the https://github.com/facebook/rocksdb/issues/6433
(https://github.com/facebook/rocksdb/pull/6433)

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8531

Reviewed By: siying

Differential Revision: D29717057

Pulled By: ajkr

fbshipit-source-id: 3ccad9501e5612590e54a7cf8c447118f323c7f4
This commit is contained in:
longlijian 2021-07-15 17:22:49 -07:00 committed by Facebook GitHub Bot
parent 5ad3227650
commit 4e4ec16957
9 changed files with 50 additions and 50 deletions

View File

@ -25,10 +25,10 @@ constexpr char db_path[] = "/tmp/testdb";
// enum. The goal is to capture sanitizer bugs, so the code should be // enum. The goal is to capture sanitizer bugs, so the code should be
// compiled with a given sanitizer (ASan, UBSan, MSan). // compiled with a given sanitizer (ASan, UBSan, MSan).
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
rocksdb::DB* db; ROCKSDB_NAMESPACE::DB* db;
rocksdb::Options options; ROCKSDB_NAMESPACE::Options options;
options.create_if_missing = true; options.create_if_missing = true;
rocksdb::Status status = rocksdb::DB::Open(options, db_path, &db); ROCKSDB_NAMESPACE::Status status = ROCKSDB_NAMESPACE::DB::Open(options, db_path, &db);
if (!status.ok()) { if (!status.ok()) {
return 0; return 0;
} }
@ -43,18 +43,18 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
case kPut: { case kPut: {
std::string key = fuzzed_data.ConsumeRandomLengthString(); std::string key = fuzzed_data.ConsumeRandomLengthString();
std::string val = fuzzed_data.ConsumeRandomLengthString(); std::string val = fuzzed_data.ConsumeRandomLengthString();
db->Put(rocksdb::WriteOptions(), key, val); db->Put(ROCKSDB_NAMESPACE::WriteOptions(), key, val);
break; break;
} }
case kGet: { case kGet: {
std::string key = fuzzed_data.ConsumeRandomLengthString(); std::string key = fuzzed_data.ConsumeRandomLengthString();
std::string value; std::string value;
db->Get(rocksdb::ReadOptions(), key, &value); db->Get(ROCKSDB_NAMESPACE::ReadOptions(), key, &value);
break; break;
} }
case kDelete: { case kDelete: {
std::string key = fuzzed_data.ConsumeRandomLengthString(); std::string key = fuzzed_data.ConsumeRandomLengthString();
db->Delete(rocksdb::WriteOptions(), key); db->Delete(ROCKSDB_NAMESPACE::WriteOptions(), key);
break; break;
} }
case kGetProperty: { case kGetProperty: {
@ -64,16 +64,16 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
break; break;
} }
case kIterator: { case kIterator: {
rocksdb::Iterator* it = db->NewIterator(rocksdb::ReadOptions()); ROCKSDB_NAMESPACE::Iterator* it = db->NewIterator(ROCKSDB_NAMESPACE::ReadOptions());
for (it->SeekToFirst(); it->Valid(); it->Next()) { for (it->SeekToFirst(); it->Valid(); it->Next()) {
} }
delete it; delete it;
break; break;
} }
case kSnapshot: { case kSnapshot: {
rocksdb::ReadOptions snapshot_options; ROCKSDB_NAMESPACE::ReadOptions snapshot_options;
snapshot_options.snapshot = db->GetSnapshot(); snapshot_options.snapshot = db->GetSnapshot();
rocksdb::Iterator* it = db->NewIterator(snapshot_options); ROCKSDB_NAMESPACE::Iterator* it = db->NewIterator(snapshot_options);
db->ReleaseSnapshot(snapshot_options.snapshot); db->ReleaseSnapshot(snapshot_options.snapshot);
delete it; delete it;
break; break;
@ -81,51 +81,51 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
case kOpenClose: { case kOpenClose: {
db->Close(); db->Close();
delete db; delete db;
status = rocksdb::DB::Open(options, db_path, &db); status = ROCKSDB_NAMESPACE::DB::Open(options, db_path, &db);
if (!status.ok()) { if (!status.ok()) {
rocksdb::DestroyDB(db_path, options); ROCKSDB_NAMESPACE::DestroyDB(db_path, options);
return 0; return 0;
} }
break; break;
} }
case kColumn: { case kColumn: {
rocksdb::ColumnFamilyHandle* cf; ROCKSDB_NAMESPACE::ColumnFamilyHandle* cf;
rocksdb::Status s; ROCKSDB_NAMESPACE::Status s;
s = db->CreateColumnFamily(rocksdb::ColumnFamilyOptions(), "new_cf", s = db->CreateColumnFamily(ROCKSDB_NAMESPACE::ColumnFamilyOptions(), "new_cf",
&cf); &cf);
s = db->DestroyColumnFamilyHandle(cf); s = db->DestroyColumnFamilyHandle(cf);
db->Close(); db->Close();
delete db; delete db;
// open DB with two column families // open DB with two column families
std::vector<rocksdb::ColumnFamilyDescriptor> column_families; std::vector<ROCKSDB_NAMESPACE::ColumnFamilyDescriptor> column_families;
// have to open default column family // have to open default column family
column_families.push_back(rocksdb::ColumnFamilyDescriptor( column_families.push_back(ROCKSDB_NAMESPACE::ColumnFamilyDescriptor(
rocksdb::kDefaultColumnFamilyName, rocksdb::ColumnFamilyOptions())); ROCKSDB_NAMESPACE::kDefaultColumnFamilyName, ROCKSDB_NAMESPACE::ColumnFamilyOptions()));
// open the new one, too // open the new one, too
column_families.push_back(rocksdb::ColumnFamilyDescriptor( column_families.push_back(ROCKSDB_NAMESPACE::ColumnFamilyDescriptor(
"new_cf", rocksdb::ColumnFamilyOptions())); "new_cf", ROCKSDB_NAMESPACE::ColumnFamilyOptions()));
std::vector<rocksdb::ColumnFamilyHandle*> handles; std::vector<ROCKSDB_NAMESPACE::ColumnFamilyHandle*> handles;
s = rocksdb::DB::Open(rocksdb::DBOptions(), db_path, column_families, s = ROCKSDB_NAMESPACE::DB::Open(ROCKSDB_NAMESPACE::DBOptions(), db_path, column_families,
&handles, &db); &handles, &db);
if (s.ok()) { if (s.ok()) {
std::string key1 = fuzzed_data.ConsumeRandomLengthString(); std::string key1 = fuzzed_data.ConsumeRandomLengthString();
std::string val1 = fuzzed_data.ConsumeRandomLengthString(); std::string val1 = fuzzed_data.ConsumeRandomLengthString();
std::string key2 = fuzzed_data.ConsumeRandomLengthString(); std::string key2 = fuzzed_data.ConsumeRandomLengthString();
s = db->Put(rocksdb::WriteOptions(), handles[1], key1, val1); s = db->Put(ROCKSDB_NAMESPACE::WriteOptions(), handles[1], key1, val1);
std::string value; std::string value;
s = db->Get(rocksdb::ReadOptions(), handles[1], key2, &value); s = db->Get(ROCKSDB_NAMESPACE::ReadOptions(), handles[1], key2, &value);
s = db->DropColumnFamily(handles[1]); s = db->DropColumnFamily(handles[1]);
for (auto handle : handles) { for (auto handle : handles) {
s = db->DestroyColumnFamilyHandle(handle); s = db->DestroyColumnFamilyHandle(handle);
} }
} else { } else {
status = rocksdb::DB::Open(options, db_path, &db); status = ROCKSDB_NAMESPACE::DB::Open(options, db_path, &db);
if (!status.ok()) { if (!status.ok()) {
// At this point there is no saving to do. So we exit // At this point there is no saving to do. So we exit
rocksdb::DestroyDB(db_path, rocksdb::Options()); ROCKSDB_NAMESPACE::DestroyDB(db_path, ROCKSDB_NAMESPACE::Options());
return 0; return 0;
} }
} }
@ -135,15 +135,15 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
std::string slice_start = fuzzed_data.ConsumeRandomLengthString(); std::string slice_start = fuzzed_data.ConsumeRandomLengthString();
std::string slice_end = fuzzed_data.ConsumeRandomLengthString(); std::string slice_end = fuzzed_data.ConsumeRandomLengthString();
rocksdb::Slice begin(slice_start); ROCKSDB_NAMESPACE::Slice begin(slice_start);
rocksdb::Slice end(slice_end); ROCKSDB_NAMESPACE::Slice end(slice_end);
rocksdb::CompactRangeOptions options; ROCKSDB_NAMESPACE::CompactRangeOptions options;
rocksdb::Status s = db->CompactRange(options, &begin, &end); ROCKSDB_NAMESPACE::Status s = db->CompactRange(options, &begin, &end);
break; break;
} }
case kSeekForPrev: { case kSeekForPrev: {
std::string key = fuzzed_data.ConsumeRandomLengthString(); std::string key = fuzzed_data.ConsumeRandomLengthString();
auto iter = db->NewIterator(rocksdb::ReadOptions()); auto iter = db->NewIterator(ROCKSDB_NAMESPACE::ReadOptions());
iter->SeekForPrev(key); iter->SeekForPrev(key);
delete iter; delete iter;
break; break;
@ -154,6 +154,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Cleanup DB // Cleanup DB
db->Close(); db->Close();
delete db; delete db;
rocksdb::DestroyDB(db_path, options); ROCKSDB_NAMESPACE::DestroyDB(db_path, options);
return 0; return 0;
} }

View File

@ -16,7 +16,7 @@
protobuf_mutator::libfuzzer::PostProcessorRegistration<DBOperations> reg = { protobuf_mutator::libfuzzer::PostProcessorRegistration<DBOperations> reg = {
[](DBOperations* input, unsigned int /* seed */) { [](DBOperations* input, unsigned int /* seed */) {
const rocksdb::Comparator* comparator = rocksdb::BytewiseComparator(); const ROCKSDB_NAMESPACE::Comparator* comparator = ROCKSDB_NAMESPACE::BytewiseComparator();
auto ops = input->mutable_operations(); auto ops = input->mutable_operations();
// Make sure begin <= end for DELETE_RANGE. // Make sure begin <= end for DELETE_RANGE.
for (DBOperation& op : *ops) { for (DBOperation& op : *ops) {
@ -41,22 +41,22 @@ DEFINE_PROTO_FUZZER(DBOperations& input) {
} }
const std::string kDbPath = "/tmp/db_map_fuzzer_test"; const std::string kDbPath = "/tmp/db_map_fuzzer_test";
auto fs = rocksdb::FileSystem::Default(); auto fs = ROCKSDB_NAMESPACE::FileSystem::Default();
if (fs->FileExists(kDbPath, rocksdb::IOOptions(), /*dbg=*/nullptr).ok()) { if (fs->FileExists(kDbPath, ROCKSDB_NAMESPACE::IOOptions(), /*dbg=*/nullptr).ok()) {
std::cerr << "db path " << kDbPath << " already exists" << std::endl; std::cerr << "db path " << kDbPath << " already exists" << std::endl;
abort(); abort();
} }
std::map<std::string, std::string> kv; std::map<std::string, std::string> kv;
rocksdb::DB* db = nullptr; ROCKSDB_NAMESPACE::DB* db = nullptr;
rocksdb::Options options; ROCKSDB_NAMESPACE::Options options;
options.create_if_missing = true; options.create_if_missing = true;
CHECK_OK(rocksdb::DB::Open(options, kDbPath, &db)); CHECK_OK(ROCKSDB_NAMESPACE::DB::Open(options, kDbPath, &db));
for (const DBOperation& op : input.operations()) { for (const DBOperation& op : input.operations()) {
switch (op.type()) { switch (op.type()) {
case OpType::PUT: { case OpType::PUT: {
CHECK_OK(db->Put(rocksdb::WriteOptions(), op.key(), op.value())); CHECK_OK(db->Put(ROCKSDB_NAMESPACE::WriteOptions(), op.key(), op.value()));
kv[op.key()] = op.value(); kv[op.key()] = op.value();
break; break;
} }
@ -64,13 +64,13 @@ DEFINE_PROTO_FUZZER(DBOperations& input) {
break; break;
} }
case OpType::DELETE: { case OpType::DELETE: {
CHECK_OK(db->Delete(rocksdb::WriteOptions(), op.key())); CHECK_OK(db->Delete(ROCKSDB_NAMESPACE::WriteOptions(), op.key()));
kv.erase(op.key()); kv.erase(op.key());
break; break;
} }
case OpType::DELETE_RANGE: { case OpType::DELETE_RANGE: {
// [op.key(), op.value()) corresponds to [begin, end). // [op.key(), op.value()) corresponds to [begin, end).
CHECK_OK(db->DeleteRange(rocksdb::WriteOptions(), CHECK_OK(db->DeleteRange(ROCKSDB_NAMESPACE::WriteOptions(),
db->DefaultColumnFamily(), op.key(), db->DefaultColumnFamily(), op.key(),
op.value())); op.value()));
kv.erase(kv.lower_bound(op.key()), kv.lower_bound(op.value())); kv.erase(kv.lower_bound(op.key()), kv.lower_bound(op.value()));
@ -86,9 +86,9 @@ DEFINE_PROTO_FUZZER(DBOperations& input) {
delete db; delete db;
db = nullptr; db = nullptr;
CHECK_OK(rocksdb::DB::Open(options, kDbPath, &db)); CHECK_OK(ROCKSDB_NAMESPACE::DB::Open(options, kDbPath, &db));
auto kv_it = kv.begin(); auto kv_it = kv.begin();
rocksdb::Iterator* it = db->NewIterator(rocksdb::ReadOptions()); ROCKSDB_NAMESPACE::Iterator* it = db->NewIterator(ROCKSDB_NAMESPACE::ReadOptions());
for (it->SeekToFirst(); it->Valid(); it->Next(), kv_it++) { for (it->SeekToFirst(); it->Valid(); it->Next(), kv_it++) {
CHECK_TRUE(kv_it != kv.end()); CHECK_TRUE(kv_it != kv.end());
CHECK_EQ(it->key().ToString(), kv_it->first); CHECK_EQ(it->key().ToString(), kv_it->first);
@ -99,5 +99,5 @@ DEFINE_PROTO_FUZZER(DBOperations& input) {
CHECK_OK(db->Close()); CHECK_OK(db->Close());
delete db; delete db;
CHECK_OK(rocksdb::DestroyDB(kDbPath, options)); CHECK_OK(ROCKSDB_NAMESPACE::DestroyDB(kDbPath, options));
} }

View File

@ -4,7 +4,7 @@
// (found in the LICENSE.Apache file in the root directory). // (found in the LICENSE.Apache file in the root directory).
// //
// This file implements the "bridge" between Java and C++ for // This file implements the "bridge" between Java and C++ for
// rocksdb::EventListener. // ROCKSDB_NAMESPACE::EventListener.
#include <jni.h> #include <jni.h>

View File

@ -4,7 +4,7 @@
// (found in the LICENSE.Apache file in the root directory). // (found in the LICENSE.Apache file in the root directory).
// //
// This file implements the callback "bridge" between Java and C++ for // This file implements the callback "bridge" between Java and C++ for
// rocksdb::EventListener. // ROCKSDB_NAMESPACE::EventListener.
#include "rocksjni/event_listener_jnicallback.h" #include "rocksjni/event_listener_jnicallback.h"

View File

@ -4,7 +4,7 @@
// (found in the LICENSE.Apache file in the root directory). // (found in the LICENSE.Apache file in the root directory).
// //
// This file implements the callback "bridge" between Java and C++ for // This file implements the callback "bridge" between Java and C++ for
// rocksdb::EventListener. // ROCKSDB_NAMESPACE::EventListener.
#ifndef JAVA_ROCKSJNI_EVENT_LISTENER_JNICALLBACK_H_ #ifndef JAVA_ROCKSJNI_EVENT_LISTENER_JNICALLBACK_H_
#define JAVA_ROCKSJNI_EVENT_LISTENER_JNICALLBACK_H_ #define JAVA_ROCKSJNI_EVENT_LISTENER_JNICALLBACK_H_

View File

@ -7731,7 +7731,7 @@ class SanityLevelJni {
class EnabledEventCallbackJni { class EnabledEventCallbackJni {
public: public:
// Returns the set of equivalent C++ // Returns the set of equivalent C++
// rocksdb::EnabledEventCallbackJni::EnabledEventCallback enums for // ROCKSDB_NAMESPACE::EnabledEventCallbackJni::EnabledEventCallback enums for
// the provided Java jenabled_event_callback_values // the provided Java jenabled_event_callback_values
static std::set<EnabledEventCallback> toCppEnabledEventCallbacks( static std::set<EnabledEventCallback> toCppEnabledEventCallbacks(
jlong jenabled_event_callback_values) { jlong jenabled_event_callback_values) {

View File

@ -2692,7 +2692,7 @@ jobjectArray Java_org_rocksdb_RocksDB_compactFiles(
void Java_org_rocksdb_RocksDB_cancelAllBackgroundWork( void Java_org_rocksdb_RocksDB_cancelAllBackgroundWork(
JNIEnv*, jobject, jlong jdb_handle, jboolean jwait) { JNIEnv*, jobject, jlong jdb_handle, jboolean jwait) {
auto* db = reinterpret_cast<ROCKSDB_NAMESPACE::DB*>(jdb_handle); auto* db = reinterpret_cast<ROCKSDB_NAMESPACE::DB*>(jdb_handle);
rocksdb::CancelAllBackgroundWork(db, jwait); ROCKSDB_NAMESPACE::CancelAllBackgroundWork(db, jwait);
} }
/* /*

View File

@ -235,7 +235,7 @@ void Java_org_rocksdb_Slice_removePrefix0(JNIEnv* /*env*/, jobject /*jobj*/,
*/ */
void Java_org_rocksdb_DirectSlice_setLength0(JNIEnv* /*env*/, jobject /*jobj*/, void Java_org_rocksdb_DirectSlice_setLength0(JNIEnv* /*env*/, jobject /*jobj*/,
jlong handle, jint length) { jlong handle, jint length) {
auto* slice = reinterpret_cast<rocksdb::Slice*>(handle); auto* slice = reinterpret_cast<ROCKSDB_NAMESPACE::Slice*>(handle);
slice->size_ = length; slice->size_ = length;
} }

View File

@ -1,5 +1,5 @@
/* /*
A wrapper around rocksdb::TransactionDBMutexFactory-provided condition and A wrapper around ROCKSDB_NAMESPACE::TransactionDBMutexFactory-provided condition and
mutex that provides toku_pthread_*-like interface. The functions are named mutex that provides toku_pthread_*-like interface. The functions are named
toku_external_{mutex|cond}_XXX toku_external_{mutex|cond}_XXX