From 4e4ec1695759ff99af75d3b649bef93d45640676 Mon Sep 17 00:00:00 2001 From: longlijian Date: Thu, 15 Jul 2021 17:22:49 -0700 Subject: [PATCH] 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 --- fuzz/db_fuzzer.cc | 62 +++++++++---------- fuzz/db_map_fuzzer.cc | 24 +++---- java/rocksjni/event_listener.cc | 2 +- java/rocksjni/event_listener_jnicallback.cc | 2 +- java/rocksjni/event_listener_jnicallback.h | 2 +- java/rocksjni/portal.h | 2 +- java/rocksjni/rocksjni.cc | 2 +- java/rocksjni/slice.cc | 2 +- .../lib/portability/toku_external_pthread.h | 2 +- 9 files changed, 50 insertions(+), 50 deletions(-) diff --git a/fuzz/db_fuzzer.cc b/fuzz/db_fuzzer.cc index 10b4fb8df0..4a4e1fe3f5 100644 --- a/fuzz/db_fuzzer.cc +++ b/fuzz/db_fuzzer.cc @@ -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 column_families; + std::vector 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 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 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; } diff --git a/fuzz/db_map_fuzzer.cc b/fuzz/db_map_fuzzer.cc index 4d9637ad90..d91ebbf98d 100644 --- a/fuzz/db_map_fuzzer.cc +++ b/fuzz/db_map_fuzzer.cc @@ -16,7 +16,7 @@ protobuf_mutator::libfuzzer::PostProcessorRegistration 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 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)); } diff --git a/java/rocksjni/event_listener.cc b/java/rocksjni/event_listener.cc index 5b07ffc9be..a3b43b0291 100644 --- a/java/rocksjni/event_listener.cc +++ b/java/rocksjni/event_listener.cc @@ -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 diff --git a/java/rocksjni/event_listener_jnicallback.cc b/java/rocksjni/event_listener_jnicallback.cc index 6e4d8975ed..cfb5d8c23c 100644 --- a/java/rocksjni/event_listener_jnicallback.cc +++ b/java/rocksjni/event_listener_jnicallback.cc @@ -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" diff --git a/java/rocksjni/event_listener_jnicallback.h b/java/rocksjni/event_listener_jnicallback.h index e3b5d0e940..b1802b341f 100644 --- a/java/rocksjni/event_listener_jnicallback.h +++ b/java/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_ diff --git a/java/rocksjni/portal.h b/java/rocksjni/portal.h index 3800c8324e..ce2c96a921 100644 --- a/java/rocksjni/portal.h +++ b/java/rocksjni/portal.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 toCppEnabledEventCallbacks( jlong jenabled_event_callback_values) { diff --git a/java/rocksjni/rocksjni.cc b/java/rocksjni/rocksjni.cc index 054c0fc89f..d00b676da4 100644 --- a/java/rocksjni/rocksjni.cc +++ b/java/rocksjni/rocksjni.cc @@ -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(jdb_handle); - rocksdb::CancelAllBackgroundWork(db, jwait); + ROCKSDB_NAMESPACE::CancelAllBackgroundWork(db, jwait); } /* diff --git a/java/rocksjni/slice.cc b/java/rocksjni/slice.cc index 00ee8e7e22..e670174bee 100644 --- a/java/rocksjni/slice.cc +++ b/java/rocksjni/slice.cc @@ -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(handle); + auto* slice = reinterpret_cast(handle); slice->size_ = length; } diff --git a/utilities/transactions/lock/range/range_tree/lib/portability/toku_external_pthread.h b/utilities/transactions/lock/range/range_tree/lib/portability/toku_external_pthread.h index b9f9c3e01e..456d5a94a2 100644 --- a/utilities/transactions/lock/range/range_tree/lib/portability/toku_external_pthread.h +++ b/utilities/transactions/lock/range/range_tree/lib/portability/toku_external_pthread.h @@ -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