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
main
longlijian 3 years ago committed by Facebook GitHub Bot
parent 5ad3227650
commit 4e4ec16957
  1. 62
      fuzz/db_fuzzer.cc
  2. 24
      fuzz/db_map_fuzzer.cc
  3. 2
      java/rocksjni/event_listener.cc
  4. 2
      java/rocksjni/event_listener_jnicallback.cc
  5. 2
      java/rocksjni/event_listener_jnicallback.h
  6. 2
      java/rocksjni/portal.h
  7. 2
      java/rocksjni/rocksjni.cc
  8. 2
      java/rocksjni/slice.cc
  9. 2
      utilities/transactions/lock/range/range_tree/lib/portability/toku_external_pthread.h

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

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

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

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

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

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

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

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

@ -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
toku_external_{mutex|cond}_XXX

Loading…
Cancel
Save