diff --git a/db/forward_iterator_bench.cc b/db/forward_iterator_bench.cc index 6f1223537..f03c734d6 100644 --- a/db/forward_iterator_bench.cc +++ b/db/forward_iterator_bench.cc @@ -272,7 +272,6 @@ struct StatsThread { : db_(db), thread_(&StatsThread::run, this) {} void run() { - // using namespace std::chrono; auto tstart = std::chrono::steady_clock::now(), tlast = tstart; uint64_t wlast = 0, rlast = 0; while (!done_.load()) { diff --git a/db/manual_compaction_test.cc b/db/manual_compaction_test.cc index 9005e932a..2eb4812c7 100644 --- a/db/manual_compaction_test.cc +++ b/db/manual_compaction_test.cc @@ -13,7 +13,19 @@ #include "rocksdb/write_batch.h" #include "test_util/testharness.h" -using namespace ROCKSDB_NAMESPACE; +using ROCKSDB_NAMESPACE::CompactionFilter; +using ROCKSDB_NAMESPACE::CompactionStyle; +using ROCKSDB_NAMESPACE::CompactRangeOptions; +using ROCKSDB_NAMESPACE::CompressionType; +using ROCKSDB_NAMESPACE::DB; +using ROCKSDB_NAMESPACE::DestroyDB; +using ROCKSDB_NAMESPACE::FlushOptions; +using ROCKSDB_NAMESPACE::Iterator; +using ROCKSDB_NAMESPACE::Options; +using ROCKSDB_NAMESPACE::ReadOptions; +using ROCKSDB_NAMESPACE::Slice; +using ROCKSDB_NAMESPACE::WriteBatch; +using ROCKSDB_NAMESPACE::WriteOptions; namespace { @@ -38,7 +50,8 @@ class ManualCompactionTest : public testing::Test { public: ManualCompactionTest() { // Get rid of any state from an old run. - dbname_ = test::PerThreadDBPath("rocksdb_manual_compaction_test"); + dbname_ = ROCKSDB_NAMESPACE::test::PerThreadDBPath( + "rocksdb_manual_compaction_test"); DestroyDB(dbname_, Options()); } @@ -91,12 +104,12 @@ TEST_F(ManualCompactionTest, CompactTouchesAllKeys) { Options options; if (iter == 0) { // level compaction options.num_levels = 3; - options.compaction_style = kCompactionStyleLevel; + options.compaction_style = CompactionStyle::kCompactionStyleLevel; } else { // universal compaction - options.compaction_style = kCompactionStyleUniversal; + options.compaction_style = CompactionStyle::kCompactionStyleUniversal; } options.create_if_missing = true; - options.compression = kNoCompression; + options.compression = CompressionType::kNoCompression; options.compaction_filter = new DestroyAllCompactionFilter(); ASSERT_OK(DB::Open(options, dbname_, &db)); @@ -129,7 +142,7 @@ TEST_F(ManualCompactionTest, Test) { Options db_options; db_options.write_buffer_size = 1024; db_options.create_if_missing = true; - db_options.compression = kNoCompression; + db_options.compression = CompressionType::kNoCompression; ASSERT_OK(DB::Open(db_options, dbname_, &db)); // create first key range @@ -182,9 +195,9 @@ TEST_F(ManualCompactionTest, SkipLevel) { options.num_levels = 3; // Initially, flushed L0 files won't exceed 100. options.level0_file_num_compaction_trigger = 100; - options.compaction_style = kCompactionStyleLevel; + options.compaction_style = CompactionStyle::kCompactionStyleLevel; options.create_if_missing = true; - options.compression = kNoCompression; + options.compression = CompressionType::kNoCompression; LogCompactionFilter* filter = new LogCompactionFilter(); options.compaction_filter = filter; ASSERT_OK(DB::Open(options, dbname_, &db)); diff --git a/examples/column_families_example.cc b/examples/column_families_example.cc index 12c9cf47e..d28b8e776 100644 --- a/examples/column_families_example.cc +++ b/examples/column_families_example.cc @@ -10,14 +10,24 @@ #include "rocksdb/slice.h" #include "rocksdb/options.h" -using namespace ROCKSDB_NAMESPACE; - #if defined(OS_WIN) std::string kDBPath = "C:\\Windows\\TEMP\\rocksdb_column_families_example"; #else std::string kDBPath = "/tmp/rocksdb_column_families_example"; #endif +using ROCKSDB_NAMESPACE::ColumnFamilyDescriptor; +using ROCKSDB_NAMESPACE::ColumnFamilyHandle; +using ROCKSDB_NAMESPACE::ColumnFamilyOptions; +using ROCKSDB_NAMESPACE::DB; +using ROCKSDB_NAMESPACE::DBOptions; +using ROCKSDB_NAMESPACE::Options; +using ROCKSDB_NAMESPACE::ReadOptions; +using ROCKSDB_NAMESPACE::Slice; +using ROCKSDB_NAMESPACE::Status; +using ROCKSDB_NAMESPACE::WriteBatch; +using ROCKSDB_NAMESPACE::WriteOptions; + int main() { // open DB Options options; @@ -40,7 +50,7 @@ int main() { std::vector column_families; // have to open default column family column_families.push_back(ColumnFamilyDescriptor( - kDefaultColumnFamilyName, ColumnFamilyOptions())); + ROCKSDB_NAMESPACE::kDefaultColumnFamilyName, ColumnFamilyOptions())); // open the new one, too column_families.push_back(ColumnFamilyDescriptor( "new_cf", ColumnFamilyOptions())); diff --git a/examples/compact_files_example.cc b/examples/compact_files_example.cc index 01e7d94d5..e56b30d59 100644 --- a/examples/compact_files_example.cc +++ b/examples/compact_files_example.cc @@ -12,7 +12,15 @@ #include "rocksdb/env.h" #include "rocksdb/options.h" -using namespace ROCKSDB_NAMESPACE; +using ROCKSDB_NAMESPACE::ColumnFamilyMetaData; +using ROCKSDB_NAMESPACE::CompactionOptions; +using ROCKSDB_NAMESPACE::DB; +using ROCKSDB_NAMESPACE::EventListener; +using ROCKSDB_NAMESPACE::FlushJobInfo; +using ROCKSDB_NAMESPACE::Options; +using ROCKSDB_NAMESPACE::ReadOptions; +using ROCKSDB_NAMESPACE::Status; +using ROCKSDB_NAMESPACE::WriteOptions; #if defined(OS_WIN) std::string kDBPath = "C:\\Windows\\TEMP\\rocksdb_compact_files_example"; @@ -142,7 +150,7 @@ int main() { Options options; options.create_if_missing = true; // Disable RocksDB background compaction. - options.compaction_style = kCompactionStyleNone; + options.compaction_style = ROCKSDB_NAMESPACE::kCompactionStyleNone; // Small slowdown and stop trigger for experimental purpose. options.level0_slowdown_writes_trigger = 3; options.level0_stop_writes_trigger = 5; @@ -150,7 +158,7 @@ int main() { options.listeners.emplace_back(new FullCompactor(options)); DB* db = nullptr; - DestroyDB(kDBPath, options); + ROCKSDB_NAMESPACE::DestroyDB(kDBPath, options); Status s = DB::Open(options, kDBPath, &db); assert(s.ok()); assert(db); diff --git a/examples/optimistic_transaction_example.cc b/examples/optimistic_transaction_example.cc index e398ad05e..e0398f66e 100644 --- a/examples/optimistic_transaction_example.cc +++ b/examples/optimistic_transaction_example.cc @@ -11,7 +11,15 @@ #include "rocksdb/utilities/transaction.h" #include "rocksdb/utilities/optimistic_transaction_db.h" -using namespace ROCKSDB_NAMESPACE; +using ROCKSDB_NAMESPACE::DB; +using ROCKSDB_NAMESPACE::OptimisticTransactionDB; +using ROCKSDB_NAMESPACE::OptimisticTransactionOptions; +using ROCKSDB_NAMESPACE::Options; +using ROCKSDB_NAMESPACE::ReadOptions; +using ROCKSDB_NAMESPACE::Snapshot; +using ROCKSDB_NAMESPACE::Status; +using ROCKSDB_NAMESPACE::Transaction; +using ROCKSDB_NAMESPACE::WriteOptions; #if defined(OS_WIN) std::string kDBPath = "C:\\Windows\\TEMP\\rocksdb_transaction_example"; diff --git a/examples/options_file_example.cc b/examples/options_file_example.cc index 92c577b15..00632f391 100644 --- a/examples/options_file_example.cc +++ b/examples/options_file_example.cc @@ -18,7 +18,18 @@ #include "rocksdb/table.h" #include "rocksdb/utilities/options_util.h" -using namespace ROCKSDB_NAMESPACE; +using ROCKSDB_NAMESPACE::BlockBasedTableOptions; +using ROCKSDB_NAMESPACE::ColumnFamilyDescriptor; +using ROCKSDB_NAMESPACE::ColumnFamilyHandle; +using ROCKSDB_NAMESPACE::ColumnFamilyOptions; +using ROCKSDB_NAMESPACE::CompactionFilter; +using ROCKSDB_NAMESPACE::ConfigOptions; +using ROCKSDB_NAMESPACE::DB; +using ROCKSDB_NAMESPACE::DBOptions; +using ROCKSDB_NAMESPACE::NewLRUCache; +using ROCKSDB_NAMESPACE::Options; +using ROCKSDB_NAMESPACE::Slice; +using ROCKSDB_NAMESPACE::Status; #if defined(OS_WIN) std::string kDBPath = "C:\\Windows\\TEMP\\rocksdb_options_file_example"; @@ -45,7 +56,8 @@ int main() { db_opt.create_if_missing = true; std::vector cf_descs; - cf_descs.push_back({kDefaultColumnFamilyName, ColumnFamilyOptions()}); + cf_descs.push_back( + {ROCKSDB_NAMESPACE::kDefaultColumnFamilyName, ColumnFamilyOptions()}); cf_descs.push_back({"new_cf", ColumnFamilyOptions()}); // initialize BlockBasedTableOptions @@ -63,7 +75,8 @@ int main() { // destroy and open DB DB* db; - Status s = DestroyDB(kDBPath, Options(db_opt, cf_descs[0].options)); + Status s = ROCKSDB_NAMESPACE::DestroyDB(kDBPath, + Options(db_opt, cf_descs[0].options)); assert(s.ok()); s = DB::Open(Options(db_opt, cf_descs[0].options), kDBPath, &db); assert(s.ok()); diff --git a/examples/simple_example.cc b/examples/simple_example.cc index c821a5c66..24e97506e 100644 --- a/examples/simple_example.cc +++ b/examples/simple_example.cc @@ -10,7 +10,13 @@ #include "rocksdb/slice.h" #include "rocksdb/options.h" -using namespace ROCKSDB_NAMESPACE; +using ROCKSDB_NAMESPACE::DB; +using ROCKSDB_NAMESPACE::Options; +using ROCKSDB_NAMESPACE::PinnableSlice; +using ROCKSDB_NAMESPACE::ReadOptions; +using ROCKSDB_NAMESPACE::Status; +using ROCKSDB_NAMESPACE::WriteBatch; +using ROCKSDB_NAMESPACE::WriteOptions; #if defined(OS_WIN) std::string kDBPath = "C:\\Windows\\TEMP\\rocksdb_simple_example"; diff --git a/examples/transaction_example.cc b/examples/transaction_example.cc index 051b968de..08bcca1b6 100644 --- a/examples/transaction_example.cc +++ b/examples/transaction_example.cc @@ -11,7 +11,15 @@ #include "rocksdb/utilities/transaction.h" #include "rocksdb/utilities/transaction_db.h" -using namespace ROCKSDB_NAMESPACE; +using ROCKSDB_NAMESPACE::Options; +using ROCKSDB_NAMESPACE::ReadOptions; +using ROCKSDB_NAMESPACE::Snapshot; +using ROCKSDB_NAMESPACE::Status; +using ROCKSDB_NAMESPACE::Transaction; +using ROCKSDB_NAMESPACE::TransactionDB; +using ROCKSDB_NAMESPACE::TransactionDBOptions; +using ROCKSDB_NAMESPACE::TransactionOptions; +using ROCKSDB_NAMESPACE::WriteOptions; #if defined(OS_WIN) std::string kDBPath = "C:\\Windows\\TEMP\\rocksdb_transaction_example"; @@ -183,7 +191,7 @@ int main() { // Cleanup delete txn_db; - DestroyDB(kDBPath, options); + ROCKSDB_NAMESPACE::DestroyDB(kDBPath, options); return 0; } diff --git a/fuzz/sst_file_writer_fuzzer.cc b/fuzz/sst_file_writer_fuzzer.cc index a21544943..ab0af8872 100644 --- a/fuzz/sst_file_writer_fuzzer.cc +++ b/fuzz/sst_file_writer_fuzzer.cc @@ -15,8 +15,6 @@ #include "table/table_reader.h" #include "util.h" -using namespace ROCKSDB_NAMESPACE; - // Keys in SST file writer operations must be unique and in ascending order. // For each DBOperation generated by the fuzzer, this function is called on // it to deduplicate and sort the keys in the DBOperations. diff --git a/java/rocksjni/testable_event_listener.cc b/java/rocksjni/testable_event_listener.cc index d5f2605a4..9fc79c5d3 100644 --- a/java/rocksjni/testable_event_listener.cc +++ b/java/rocksjni/testable_event_listener.cc @@ -11,7 +11,25 @@ #include "rocksdb/status.h" #include "rocksdb/table_properties.h" -using namespace ROCKSDB_NAMESPACE; +using ROCKSDB_NAMESPACE::BackgroundErrorReason; +using ROCKSDB_NAMESPACE::CompactionJobInfo; +using ROCKSDB_NAMESPACE::CompactionJobStats; +using ROCKSDB_NAMESPACE::CompactionReason; +using ROCKSDB_NAMESPACE::CompressionType; +using ROCKSDB_NAMESPACE::ExternalFileIngestionInfo; +using ROCKSDB_NAMESPACE::FileOperationInfo; +using ROCKSDB_NAMESPACE::FileOperationType; +using ROCKSDB_NAMESPACE::FlushJobInfo; +using ROCKSDB_NAMESPACE::FlushReason; +using ROCKSDB_NAMESPACE::MemTableInfo; +using ROCKSDB_NAMESPACE::Status; +using ROCKSDB_NAMESPACE::TableFileCreationBriefInfo; +using ROCKSDB_NAMESPACE::TableFileCreationInfo; +using ROCKSDB_NAMESPACE::TableFileCreationReason; +using ROCKSDB_NAMESPACE::TableFileDeletionInfo; +using ROCKSDB_NAMESPACE::TableProperties; +using ROCKSDB_NAMESPACE::WriteStallCondition; +using ROCKSDB_NAMESPACE::WriteStallInfo; static TableProperties newTablePropertiesForTest() { TableProperties table_properties; diff --git a/java/rocksjni/transaction.cc b/java/rocksjni/transaction.cc index 720285e75..444730667 100644 --- a/java/rocksjni/transaction.cc +++ b/java/rocksjni/transaction.cc @@ -14,8 +14,6 @@ #include "rocksdb/utilities/transaction.h" #include "rocksjni/portal.h" -using namespace std::placeholders; - #if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable : 4503) // identifier' : decorated name length @@ -220,8 +218,8 @@ jbyteArray Java_org_rocksdb_Transaction_get__JJ_3BIJ( const ROCKSDB_NAMESPACE::ReadOptions&, ROCKSDB_NAMESPACE::ColumnFamilyHandle*, const ROCKSDB_NAMESPACE::Slice&, std::string*)>( - &ROCKSDB_NAMESPACE::Transaction::Get, txn, _1, column_family_handle, - _2, _3); + &ROCKSDB_NAMESPACE::Transaction::Get, txn, std::placeholders::_1, + column_family_handle, std::placeholders::_2, std::placeholders::_3); return txn_get_helper(env, fn_get, jread_options_handle, jkey, jkey_part_len); } @@ -238,7 +236,8 @@ jbyteArray Java_org_rocksdb_Transaction_get__JJ_3BI( std::bind( - &ROCKSDB_NAMESPACE::Transaction::Get, txn, _1, _2, _3); + &ROCKSDB_NAMESPACE::Transaction::Get, txn, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); return txn_get_helper(env, fn_get, jread_options_handle, jkey, jkey_part_len); } @@ -402,8 +401,8 @@ jobjectArray Java_org_rocksdb_Transaction_multiGet__JJ_3_3B_3J( const ROCKSDB_NAMESPACE::ReadOptions&, const std::vector&, const std::vector&, std::vector*)>( - &ROCKSDB_NAMESPACE::Transaction::MultiGet, txn, _1, column_family_handles, - _2, _3); + &ROCKSDB_NAMESPACE::Transaction::MultiGet, txn, std::placeholders::_1, + column_family_handles, std::placeholders::_2, std::placeholders::_3); return txn_multi_get_helper(env, fn_multi_get, jread_options_handle, jkey_parts); } @@ -421,7 +420,8 @@ jobjectArray Java_org_rocksdb_Transaction_multiGet__JJ_3_3B( ROCKSDB_NAMESPACE::Transaction::*)( const ROCKSDB_NAMESPACE::ReadOptions&, const std::vector&, std::vector*)>( - &ROCKSDB_NAMESPACE::Transaction::MultiGet, txn, _1, _2, _3); + &ROCKSDB_NAMESPACE::Transaction::MultiGet, txn, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); return txn_multi_get_helper(env, fn_multi_get, jread_options_handle, jkey_parts); } @@ -444,8 +444,9 @@ jbyteArray Java_org_rocksdb_Transaction_getForUpdate__JJ_3BIJZZ( const ROCKSDB_NAMESPACE::ReadOptions&, ROCKSDB_NAMESPACE::ColumnFamilyHandle*, const ROCKSDB_NAMESPACE::Slice&, std::string*, bool, bool)>( - &ROCKSDB_NAMESPACE::Transaction::GetForUpdate, txn, _1, - column_family_handle, _2, _3, jexclusive, jdo_validate); + &ROCKSDB_NAMESPACE::Transaction::GetForUpdate, txn, + std::placeholders::_1, column_family_handle, std::placeholders::_2, + std::placeholders::_3, jexclusive, jdo_validate); return txn_get_helper(env, fn_get_for_update, jread_options_handle, jkey, jkey_part_len); } @@ -464,7 +465,8 @@ jbyteArray Java_org_rocksdb_Transaction_getForUpdate__JJ_3BIZZ( std::bind( - &ROCKSDB_NAMESPACE::Transaction::GetForUpdate, txn, _1, _2, _3, + &ROCKSDB_NAMESPACE::Transaction::GetForUpdate, txn, + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, jexclusive, jdo_validate); return txn_get_helper(env, fn_get_for_update, jread_options_handle, jkey, jkey_part_len); @@ -492,8 +494,9 @@ jobjectArray Java_org_rocksdb_Transaction_multiGetForUpdate__JJ_3_3B_3J( const ROCKSDB_NAMESPACE::ReadOptions&, const std::vector&, const std::vector&, std::vector*)>( - &ROCKSDB_NAMESPACE::Transaction::MultiGetForUpdate, txn, _1, - column_family_handles, _2, _3); + &ROCKSDB_NAMESPACE::Transaction::MultiGetForUpdate, txn, + std::placeholders::_1, column_family_handles, std::placeholders::_2, + std::placeholders::_3); return txn_multi_get_helper(env, fn_multi_get_for_update, jread_options_handle, jkey_parts); } @@ -511,7 +514,8 @@ jobjectArray Java_org_rocksdb_Transaction_multiGetForUpdate__JJ_3_3B( ROCKSDB_NAMESPACE::Status> (ROCKSDB_NAMESPACE::Transaction::*)( const ROCKSDB_NAMESPACE::ReadOptions&, const std::vector&, std::vector*)>( - &ROCKSDB_NAMESPACE::Transaction::MultiGetForUpdate, txn, _1, _2, _3); + &ROCKSDB_NAMESPACE::Transaction::MultiGetForUpdate, txn, + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); return txn_multi_get_helper(env, fn_multi_get_for_update, jread_options_handle, jkey_parts); } @@ -605,7 +609,8 @@ void Java_org_rocksdb_Transaction_put__J_3BI_3BIJZ( ROCKSDB_NAMESPACE::ColumnFamilyHandle*, const ROCKSDB_NAMESPACE::Slice&, const ROCKSDB_NAMESPACE::Slice&, bool)>(&ROCKSDB_NAMESPACE::Transaction::Put, txn, - column_family_handle, _1, _2, jassume_tracked); + column_family_handle, std::placeholders::_1, + std::placeholders::_2, jassume_tracked); txn_write_kv_helper(env, fn_put, jkey, jkey_part_len, jval, jval_len); } @@ -623,7 +628,8 @@ void Java_org_rocksdb_Transaction_put__J_3BI_3BI(JNIEnv* env, jobject /*jobj*/, FnWriteKV fn_put = std::bind( - &ROCKSDB_NAMESPACE::Transaction::Put, txn, _1, _2); + &ROCKSDB_NAMESPACE::Transaction::Put, txn, std::placeholders::_1, + std::placeholders::_2); txn_write_kv_helper(env, fn_put, jkey, jkey_part_len, jval, jval_len); } @@ -750,8 +756,8 @@ void Java_org_rocksdb_Transaction_put__J_3_3BI_3_3BIJZ( ROCKSDB_NAMESPACE::ColumnFamilyHandle*, const ROCKSDB_NAMESPACE::SliceParts&, const ROCKSDB_NAMESPACE::SliceParts&, bool)>( - &ROCKSDB_NAMESPACE::Transaction::Put, txn, column_family_handle, _1, - _2, jassume_tracked); + &ROCKSDB_NAMESPACE::Transaction::Put, txn, column_family_handle, + std::placeholders::_1, std::placeholders::_2, jassume_tracked); txn_write_kv_parts_helper(env, fn_put_parts, jkey_parts, jkey_parts_len, jvalue_parts, jvalue_parts_len); } @@ -768,7 +774,8 @@ void Java_org_rocksdb_Transaction_put__J_3_3BI_3_3BI( FnWriteKVParts fn_put_parts = std::bind( - &ROCKSDB_NAMESPACE::Transaction::Put, txn, _1, _2); + &ROCKSDB_NAMESPACE::Transaction::Put, txn, std::placeholders::_1, + std::placeholders::_2); txn_write_kv_parts_helper(env, fn_put_parts, jkey_parts, jkey_parts_len, jvalue_parts, jvalue_parts_len); } @@ -791,7 +798,8 @@ void Java_org_rocksdb_Transaction_merge__J_3BI_3BIJZ( ROCKSDB_NAMESPACE::ColumnFamilyHandle*, const ROCKSDB_NAMESPACE::Slice&, const ROCKSDB_NAMESPACE::Slice&, bool)>(&ROCKSDB_NAMESPACE::Transaction::Merge, txn, - column_family_handle, _1, _2, jassume_tracked); + column_family_handle, std::placeholders::_1, + std::placeholders::_2, jassume_tracked); txn_write_kv_helper(env, fn_merge, jkey, jkey_part_len, jval, jval_len); } @@ -807,7 +815,8 @@ void Java_org_rocksdb_Transaction_merge__J_3BI_3BI( FnWriteKV fn_merge = std::bind( - &ROCKSDB_NAMESPACE::Transaction::Merge, txn, _1, _2); + &ROCKSDB_NAMESPACE::Transaction::Merge, txn, std::placeholders::_1, + std::placeholders::_2); txn_write_kv_helper(env, fn_merge, jkey, jkey_part_len, jval, jval_len); } @@ -856,7 +865,7 @@ void Java_org_rocksdb_Transaction_delete__J_3BIJZ( ROCKSDB_NAMESPACE::ColumnFamilyHandle*, const ROCKSDB_NAMESPACE::Slice&, bool)>( &ROCKSDB_NAMESPACE::Transaction::Delete, txn, column_family_handle, - _1, jassume_tracked); + std::placeholders::_1, jassume_tracked); txn_write_k_helper(env, fn_delete, jkey, jkey_part_len); } @@ -871,7 +880,7 @@ void Java_org_rocksdb_Transaction_delete__J_3BI(JNIEnv* env, jobject /*jobj*/, auto* txn = reinterpret_cast(jhandle); FnWriteK fn_delete = std::bind( - &ROCKSDB_NAMESPACE::Transaction::Delete, txn, _1); + &ROCKSDB_NAMESPACE::Transaction::Delete, txn, std::placeholders::_1); txn_write_k_helper(env, fn_delete, jkey, jkey_part_len); } @@ -951,7 +960,7 @@ void Java_org_rocksdb_Transaction_delete__J_3_3BIJZ( ROCKSDB_NAMESPACE::ColumnFamilyHandle*, const ROCKSDB_NAMESPACE::SliceParts&, bool)>( &ROCKSDB_NAMESPACE::Transaction::Delete, txn, column_family_handle, - _1, jassume_tracked); + std::placeholders::_1, jassume_tracked); txn_write_k_parts_helper(env, fn_delete_parts, jkey_parts, jkey_parts_len); } @@ -967,7 +976,7 @@ void Java_org_rocksdb_Transaction_delete__J_3_3BI(JNIEnv* env, jobject /*jobj*/, auto* txn = reinterpret_cast(jhandle); FnWriteKParts fn_delete_parts = std::bind( - &ROCKSDB_NAMESPACE::Transaction::Delete, txn, _1); + &ROCKSDB_NAMESPACE::Transaction::Delete, txn, std::placeholders::_1); txn_write_k_parts_helper(env, fn_delete_parts, jkey_parts, jkey_parts_len); } @@ -988,7 +997,7 @@ void Java_org_rocksdb_Transaction_singleDelete__J_3BIJZ( ROCKSDB_NAMESPACE::ColumnFamilyHandle*, const ROCKSDB_NAMESPACE::Slice&, bool)>( &ROCKSDB_NAMESPACE::Transaction::SingleDelete, txn, - column_family_handle, _1, jassume_tracked); + column_family_handle, std::placeholders::_1, jassume_tracked); txn_write_k_helper(env, fn_single_delete, jkey, jkey_part_len); } @@ -1005,7 +1014,8 @@ void Java_org_rocksdb_Transaction_singleDelete__J_3BI(JNIEnv* env, auto* txn = reinterpret_cast(jhandle); FnWriteK fn_single_delete = std::bind( - &ROCKSDB_NAMESPACE::Transaction::SingleDelete, txn, _1); + &ROCKSDB_NAMESPACE::Transaction::SingleDelete, txn, + std::placeholders::_1); txn_write_k_helper(env, fn_single_delete, jkey, jkey_part_len); } @@ -1027,7 +1037,7 @@ void Java_org_rocksdb_Transaction_singleDelete__J_3_3BIJZ( ROCKSDB_NAMESPACE::ColumnFamilyHandle*, const ROCKSDB_NAMESPACE::SliceParts&, bool)>( &ROCKSDB_NAMESPACE::Transaction::SingleDelete, txn, - column_family_handle, _1, jassume_tracked); + column_family_handle, std::placeholders::_1, jassume_tracked); txn_write_k_parts_helper(env, fn_single_delete_parts, jkey_parts, jkey_parts_len); } @@ -1045,7 +1055,8 @@ void Java_org_rocksdb_Transaction_singleDelete__J_3_3BI(JNIEnv* env, auto* txn = reinterpret_cast(jhandle); FnWriteKParts fn_single_delete_parts = std::bind( - &ROCKSDB_NAMESPACE::Transaction::SingleDelete, txn, _1); + &ROCKSDB_NAMESPACE::Transaction::SingleDelete, txn, + std::placeholders::_1); txn_write_k_parts_helper(env, fn_single_delete_parts, jkey_parts, jkey_parts_len); } @@ -1068,7 +1079,7 @@ void Java_org_rocksdb_Transaction_putUntracked__J_3BI_3BIJ( ROCKSDB_NAMESPACE::ColumnFamilyHandle*, const ROCKSDB_NAMESPACE::Slice&, const ROCKSDB_NAMESPACE::Slice&)>( &ROCKSDB_NAMESPACE::Transaction::PutUntracked, txn, - column_family_handle, _1, _2); + column_family_handle, std::placeholders::_1, std::placeholders::_2); txn_write_kv_helper(env, fn_put_untracked, jkey, jkey_part_len, jval, jval_len); } @@ -1085,7 +1096,8 @@ void Java_org_rocksdb_Transaction_putUntracked__J_3BI_3BI( FnWriteKV fn_put_untracked = std::bind( - &ROCKSDB_NAMESPACE::Transaction::PutUntracked, txn, _1, _2); + &ROCKSDB_NAMESPACE::Transaction::PutUntracked, txn, + std::placeholders::_1, std::placeholders::_2); txn_write_kv_helper(env, fn_put_untracked, jkey, jkey_part_len, jval, jval_len); } @@ -1108,7 +1120,7 @@ void Java_org_rocksdb_Transaction_putUntracked__J_3_3BI_3_3BIJ( const ROCKSDB_NAMESPACE::SliceParts&, const ROCKSDB_NAMESPACE::SliceParts&)>( &ROCKSDB_NAMESPACE::Transaction::PutUntracked, txn, column_family_handle, - _1, _2); + std::placeholders::_1, std::placeholders::_2); txn_write_kv_parts_helper(env, fn_put_parts_untracked, jkey_parts, jkey_parts_len, jvalue_parts, jvalue_parts_len); } @@ -1125,7 +1137,8 @@ void Java_org_rocksdb_Transaction_putUntracked__J_3_3BI_3_3BI( FnWriteKVParts fn_put_parts_untracked = std::bind( - &ROCKSDB_NAMESPACE::Transaction::PutUntracked, txn, _1, _2); + &ROCKSDB_NAMESPACE::Transaction::PutUntracked, txn, std::placeholders::_1, + std::placeholders::_2); txn_write_kv_parts_helper(env, fn_put_parts_untracked, jkey_parts, jkey_parts_len, jvalue_parts, jvalue_parts_len); } @@ -1148,7 +1161,7 @@ void Java_org_rocksdb_Transaction_mergeUntracked__J_3BI_3BIJ( ROCKSDB_NAMESPACE::ColumnFamilyHandle*, const ROCKSDB_NAMESPACE::Slice&, const ROCKSDB_NAMESPACE::Slice&)>( &ROCKSDB_NAMESPACE::Transaction::MergeUntracked, txn, - column_family_handle, _1, _2); + column_family_handle, std::placeholders::_1, std::placeholders::_2); txn_write_kv_helper(env, fn_merge_untracked, jkey, jkey_part_len, jval, jval_len); } @@ -1165,7 +1178,8 @@ void Java_org_rocksdb_Transaction_mergeUntracked__J_3BI_3BI( FnWriteKV fn_merge_untracked = std::bind( - &ROCKSDB_NAMESPACE::Transaction::MergeUntracked, txn, _1, _2); + &ROCKSDB_NAMESPACE::Transaction::MergeUntracked, txn, + std::placeholders::_1, std::placeholders::_2); txn_write_kv_helper(env, fn_merge_untracked, jkey, jkey_part_len, jval, jval_len); } @@ -1186,7 +1200,7 @@ void Java_org_rocksdb_Transaction_deleteUntracked__J_3BIJ( ROCKSDB_NAMESPACE::Transaction::*)(ROCKSDB_NAMESPACE::ColumnFamilyHandle*, const ROCKSDB_NAMESPACE::Slice&)>( &ROCKSDB_NAMESPACE::Transaction::DeleteUntracked, txn, - column_family_handle, _1); + column_family_handle, std::placeholders::_1); txn_write_k_helper(env, fn_delete_untracked, jkey, jkey_part_len); } @@ -1203,7 +1217,8 @@ void Java_org_rocksdb_Transaction_deleteUntracked__J_3BI(JNIEnv* env, auto* txn = reinterpret_cast(jhandle); FnWriteK fn_delete_untracked = std::bind( - &ROCKSDB_NAMESPACE::Transaction::DeleteUntracked, txn, _1); + &ROCKSDB_NAMESPACE::Transaction::DeleteUntracked, txn, + std::placeholders::_1); txn_write_k_helper(env, fn_delete_untracked, jkey, jkey_part_len); } @@ -1224,7 +1239,7 @@ void Java_org_rocksdb_Transaction_deleteUntracked__J_3_3BIJ( ROCKSDB_NAMESPACE::ColumnFamilyHandle*, const ROCKSDB_NAMESPACE::SliceParts&)>( &ROCKSDB_NAMESPACE::Transaction::DeleteUntracked, txn, - column_family_handle, _1); + column_family_handle, std::placeholders::_1); txn_write_k_parts_helper(env, fn_delete_untracked_parts, jkey_parts, jkey_parts_len); } @@ -1241,7 +1256,8 @@ void Java_org_rocksdb_Transaction_deleteUntracked__J_3_3BI( FnWriteKParts fn_delete_untracked_parts = std::bind( - &ROCKSDB_NAMESPACE::Transaction::DeleteUntracked, txn, _1); + &ROCKSDB_NAMESPACE::Transaction::DeleteUntracked, txn, + std::placeholders::_1); txn_write_k_parts_helper(env, fn_delete_untracked_parts, jkey_parts, jkey_parts_len); } diff --git a/memtable/vectorrep.cc b/memtable/vectorrep.cc index 2386e46ab..26c699ca6 100644 --- a/memtable/vectorrep.cc +++ b/memtable/vectorrep.cc @@ -21,8 +21,6 @@ namespace ROCKSDB_NAMESPACE { namespace { -using namespace stl_wrappers; - class VectorRep : public MemTableRep { public: VectorRep(const KeyComparator& compare, Allocator* allocator, size_t count); @@ -157,14 +155,16 @@ void VectorRep::Iterator::DoSort() const { if (!sorted_ && vrep_ != nullptr) { WriteLock l(&vrep_->rwlock_); if (!vrep_->sorted_) { - std::sort(bucket_->begin(), bucket_->end(), Compare(compare_)); + std::sort(bucket_->begin(), bucket_->end(), + stl_wrappers::Compare(compare_)); cit_ = bucket_->begin(); vrep_->sorted_ = true; } sorted_ = true; } if (!sorted_) { - std::sort(bucket_->begin(), bucket_->end(), Compare(compare_)); + std::sort(bucket_->begin(), bucket_->end(), + stl_wrappers::Compare(compare_)); cit_ = bucket_->begin(); sorted_ = true; } diff --git a/port/win/env_default.cc b/port/win/env_default.cc index 0c9958ddd..48853f26e 100644 --- a/port/win/env_default.cc +++ b/port/win/env_default.cc @@ -26,18 +26,18 @@ namespace port { // dead-lock. // in this manner any remaining threads are terminated OK. namespace { - std::once_flag winenv_once_flag; - Env* envptr; -}; -} +std::once_flag winenv_once_flag; +Env* envptr; +}; // namespace +} // namespace port Env* Env::Default() { - using namespace port; ThreadLocalPtr::InitSingletons(); CompressionContextCache::InitSingleton(); INIT_SYNC_POINT_SINGLETONS(); - std::call_once(winenv_once_flag, []() { envptr = new WinEnv(); }); - return envptr; + std::call_once(port::winenv_once_flag, + []() { port::envptr = new port::WinEnv(); }); + return port::envptr; } } // namespace ROCKSDB_NAMESPACE diff --git a/port/win/env_win.cc b/port/win/env_win.cc index 1b0e70ee6..ac069d7f1 100644 --- a/port/win/env_win.cc +++ b/port/win/env_win.cc @@ -144,8 +144,8 @@ uint64_t WinClock::NowMicros() { li.QuadPart /= c_FtToMicroSec; return li.QuadPart; } - using namespace std::chrono; - return duration_cast(system_clock::now().time_since_epoch()) + return std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) .count(); } @@ -165,9 +165,8 @@ uint64_t WinClock::NowNanos() { li.QuadPart *= nano_seconds_per_period_; return li.QuadPart; } - using namespace std::chrono; - return duration_cast( - high_resolution_clock::now().time_since_epoch()) + return std::chrono::duration_cast( + std::chrono::high_resolution_clock::now().time_since_epoch()) .count(); } diff --git a/port/win/port_win.cc b/port/win/port_win.cc index f0984a9a2..38f3b7db7 100644 --- a/port/win/port_win.cc +++ b/port/win/port_win.cc @@ -27,9 +27,9 @@ #ifdef ROCKSDB_WINDOWS_UTF8_FILENAMES // utf8 <-> utf16 -#include -#include #include +#include +#include #endif #include "logging/logging.h" @@ -42,7 +42,7 @@ namespace port { #ifdef ROCKSDB_WINDOWS_UTF8_FILENAMES std::string utf16_to_utf8(const std::wstring& utf16) { - std::wstring_convert,wchar_t> convert; + std::wstring_convert, wchar_t> convert; return convert.to_bytes(utf16); } @@ -53,16 +53,17 @@ std::wstring utf8_to_utf16(const std::string& utf8) { #endif void gettimeofday(struct timeval* tv, struct timezone* /* tz */) { - using namespace std::chrono; + std::chrono::microseconds usNow( + std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch())); - microseconds usNow( - duration_cast(system_clock::now().time_since_epoch())); - - seconds secNow(duration_cast(usNow)); + std::chrono::seconds secNow( + std::chrono::duration_cast(usNow)); tv->tv_sec = static_cast(secNow.count()); - tv->tv_usec = static_cast(usNow.count() - - duration_cast(secNow).count()); + tv->tv_usec = static_cast( + usNow.count() - + std::chrono::duration_cast(secNow).count()); } Mutex::~Mutex() {} @@ -85,17 +86,16 @@ void CondVar::Wait() { } bool CondVar::TimedWait(uint64_t abs_time_us) { - - using namespace std::chrono; - // MSVC++ library implements wait_until in terms of wait_for so // we need to convert absolute wait into relative wait. - microseconds usAbsTime(abs_time_us); + std::chrono::microseconds usAbsTime(abs_time_us); - microseconds usNow( - duration_cast(system_clock::now().time_since_epoch())); - microseconds relTimeUs = - (usAbsTime > usNow) ? (usAbsTime - usNow) : microseconds::zero(); + std::chrono::microseconds usNow( + std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch())); + std::chrono::microseconds relTimeUs = (usAbsTime > usNow) + ? (usAbsTime - usNow) + : std::chrono::microseconds::zero(); // Caller must ensure that mutex is held prior to calling this method std::unique_lock lk(mu_->getLock(), std::adopt_lock); @@ -103,7 +103,7 @@ bool CondVar::TimedWait(uint64_t abs_time_us) { // Work around https://github.com/microsoft/STL/issues/369 #if defined(_MSC_VER) && \ (!defined(_MSVC_STL_UPDATE) || _MSVC_STL_UPDATE < 202008L) - if (relTimeUs == microseconds::zero()) { + if (relTimeUs == std::chrono::microseconds::zero()) { lk.unlock(); lk.lock(); } @@ -138,13 +138,12 @@ void InitOnce(OnceType* once, void (*initializer)()) { // Private structure, exposed only by pointer struct DIR { - HANDLE handle_; - bool firstread_; + HANDLE handle_; + bool firstread_; RX_WIN32_FIND_DATA data_; dirent entry_; - DIR() : handle_(INVALID_HANDLE_VALUE), - firstread_(true) {} + DIR() : handle_(INVALID_HANDLE_VALUE), firstread_(true) {} DIR(const DIR&) = delete; DIR& operator=(const DIR&) = delete; @@ -222,7 +221,6 @@ int truncate(const char* path, int64_t length) { } int Truncate(std::string path, int64_t len) { - if (len < 0) { errno = EINVAL; return -1; @@ -230,10 +228,10 @@ int Truncate(std::string path, int64_t len) { HANDLE hFile = RX_CreateFile(RX_FN(path).c_str(), GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, // Security attrs - OPEN_EXISTING, // Truncate existing file only - FILE_ATTRIBUTE_NORMAL, NULL); + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, // Security attrs + OPEN_EXISTING, // Truncate existing file only + FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hFile) { auto lastError = GetLastError(); diff --git a/third-party/folly/folly/detail/Futex.cpp b/third-party/folly/folly/detail/Futex.cpp index 62d6ea2b2..012d1a36f 100644 --- a/third-party/folly/folly/detail/Futex.cpp +++ b/third-party/folly/folly/detail/Futex.cpp @@ -20,8 +20,6 @@ #include #endif -using namespace std::chrono; - namespace folly { namespace detail { @@ -69,7 +67,7 @@ int nativeFutexWake(const void* addr, int count, uint32_t wakeMask) { } template -struct timespec timeSpecFromTimePoint(time_point absTime) { +struct timespec timeSpecFromTimePoint(std::chrono::time_point absTime) { auto epoch = absTime.time_since_epoch(); if (epoch.count() < 0) { // kernel timespec_valid requires non-negative seconds and nanos in [0,1G) @@ -79,20 +77,21 @@ struct timespec timeSpecFromTimePoint(time_point absTime) { // timespec-safe seconds and nanoseconds; // chrono::{nano,}seconds are `long long int` // whereas timespec uses smaller types - using time_t_seconds = duration; - using long_nanos = duration; + using time_t_seconds = + std::chrono::duration; + using long_nanos = + std::chrono::duration; - auto secs = duration_cast(epoch); - auto nanos = duration_cast(epoch - secs); + auto secs = std::chrono::duration_cast(epoch); + auto nanos = std::chrono::duration_cast(epoch - secs); struct timespec result = {secs.count(), nanos.count()}; return result; } FutexResult nativeFutexWaitImpl( - const void* addr, - uint32_t expected, - system_clock::time_point const* absSystemTime, - steady_clock::time_point const* absSteadyTime, + const void* addr, uint32_t expected, + std::chrono::system_clock::time_point const* absSystemTime, + std::chrono::steady_clock::time_point const* absSteadyTime, uint32_t waitMask) { assert(absSystemTime == nullptr || absSteadyTime == nullptr); @@ -171,10 +170,9 @@ int emulatedFutexWake(const void* addr, int count, uint32_t waitMask) { template FutexResult emulatedFutexWaitImpl( - F* futex, - uint32_t expected, - system_clock::time_point const* absSystemTime, - steady_clock::time_point const* absSteadyTime, + F* futex, uint32_t expected, + std::chrono::system_clock::time_point const* absSystemTime, + std::chrono::steady_clock::time_point const* absSteadyTime, uint32_t waitMask) { static_assert( std::is_same>::value || @@ -235,10 +233,9 @@ int futexWakeImpl( } FutexResult futexWaitImpl( - const Futex* futex, - uint32_t expected, - system_clock::time_point const* absSystemTime, - steady_clock::time_point const* absSteadyTime, + const Futex* futex, uint32_t expected, + std::chrono::system_clock::time_point const* absSystemTime, + std::chrono::steady_clock::time_point const* absSteadyTime, uint32_t waitMask) { #ifdef __linux__ return nativeFutexWaitImpl( @@ -250,10 +247,9 @@ FutexResult futexWaitImpl( } FutexResult futexWaitImpl( - const Futex* futex, - uint32_t expected, - system_clock::time_point const* absSystemTime, - steady_clock::time_point const* absSteadyTime, + const Futex* futex, uint32_t expected, + std::chrono::system_clock::time_point const* absSystemTime, + std::chrono::steady_clock::time_point const* absSteadyTime, uint32_t waitMask) { return emulatedFutexWaitImpl( futex, expected, absSystemTime, absSteadyTime, waitMask); diff --git a/tools/blob_dump.cc b/tools/blob_dump.cc index 2ae73ecfe..ab39b8513 100644 --- a/tools/blob_dump.cc +++ b/tools/blob_dump.cc @@ -11,8 +11,8 @@ #include "utilities/blob_db/blob_dump_tool.h" -using namespace ROCKSDB_NAMESPACE; -using namespace ROCKSDB_NAMESPACE::blob_db; +using ROCKSDB_NAMESPACE::Status; +using ROCKSDB_NAMESPACE::blob_db::BlobDumpTool; int main(int argc, char** argv) { using DisplayType = BlobDumpTool::DisplayType; diff --git a/tools/db_repl_stress.cc b/tools/db_repl_stress.cc index 7025e1040..ba680f4f2 100644 --- a/tools/db_repl_stress.cc +++ b/tools/db_repl_stress.cc @@ -35,7 +35,17 @@ DEFINE_uint64(wal_size_limit_MB, 10, "the wal size limit for the run" "(in MB)"); -using namespace ROCKSDB_NAMESPACE; +using ROCKSDB_NAMESPACE::BatchResult; +using ROCKSDB_NAMESPACE::DB; +using ROCKSDB_NAMESPACE::DestroyDB; +using ROCKSDB_NAMESPACE::Env; +using ROCKSDB_NAMESPACE::Options; +using ROCKSDB_NAMESPACE::Random; +using ROCKSDB_NAMESPACE::SequenceNumber; +using ROCKSDB_NAMESPACE::Slice; +using ROCKSDB_NAMESPACE::Status; +using ROCKSDB_NAMESPACE::TransactionLogIterator; +using ROCKSDB_NAMESPACE::WriteOptions; using GFLAGS_NAMESPACE::ParseCommandLineFlags; using GFLAGS_NAMESPACE::SetUsageMessage; diff --git a/tools/rdb/db_wrapper.cc b/tools/rdb/db_wrapper.cc index 632cf05a8..b3bb9bee9 100644 --- a/tools/rdb/db_wrapper.cc +++ b/tools/rdb/db_wrapper.cc @@ -27,9 +27,6 @@ namespace { } } -using namespace v8; - - Persistent DBWrapper::constructor; DBWrapper::DBWrapper() { diff --git a/tools/rdb/db_wrapper.h b/tools/rdb/db_wrapper.h index 4b57320cd..ece7dfefc 100644 --- a/tools/rdb/db_wrapper.h +++ b/tools/rdb/db_wrapper.h @@ -9,8 +9,6 @@ #include "rocksdb/slice.h" #include "rocksdb/options.h" -using namespace v8; - // Used to encapsulate a particular instance of an opened database. // // This object should not be used directly in C++; it exists solely to provide diff --git a/tools/rdb/rdb.cc b/tools/rdb/rdb.cc index 119fcc410..c1375bb62 100644 --- a/tools/rdb/rdb.cc +++ b/tools/rdb/rdb.cc @@ -7,8 +7,6 @@ #include #include "db/_wrapper.h" -using namespace v8; - void InitAll(Handle exports) { DBWrapper::Init(exports); } diff --git a/util/compression_context_cache.cc b/util/compression_context_cache.cc index a06cfb279..f62ac0c9b 100644 --- a/util/compression_context_cache.cc +++ b/util/compression_context_cache.cc @@ -65,8 +65,6 @@ static_assert(sizeof(ZSTDCachedData) % CACHE_LINE_SIZE == 0, "Expected CACHE_LINE_SIZE alignment"); } // namespace compression_cache -using namespace compression_cache; - class CompressionContextCache::Rep { public: Rep() {} @@ -82,7 +80,7 @@ class CompressionContextCache::Rep { } private: - CoreLocalArray per_core_uncompr_; + CoreLocalArray per_core_uncompr_; }; CompressionContextCache::CompressionContextCache() : rep_(new Rep()) {} diff --git a/utilities/merge_operators/put.cc b/utilities/merge_operators/put.cc index 2133f1b57..ba86706ef 100644 --- a/utilities/merge_operators/put.cc +++ b/utilities/merge_operators/put.cc @@ -8,10 +8,12 @@ #include "rocksdb/merge_operator.h" #include "utilities/merge_operators.h" -using namespace ROCKSDB_NAMESPACE; - namespace { // anonymous namespace +using ROCKSDB_NAMESPACE::Logger; +using ROCKSDB_NAMESPACE::MergeOperator; +using ROCKSDB_NAMESPACE::Slice; + // A merge operator that mimics Put semantics // Since this merge-operator will not be used in production, // it is implemented as a non-associative merge operator to illustrate the diff --git a/utilities/merge_operators/uint64add.cc b/utilities/merge_operators/uint64add.cc index d8e39615e..91d6af1f4 100644 --- a/utilities/merge_operators/uint64add.cc +++ b/utilities/merge_operators/uint64add.cc @@ -12,10 +12,13 @@ #include "util/coding.h" #include "utilities/merge_operators.h" -using namespace ROCKSDB_NAMESPACE; - namespace { // anonymous namespace +using ROCKSDB_NAMESPACE::AssociativeMergeOperator; +using ROCKSDB_NAMESPACE::InfoLogLevel; +using ROCKSDB_NAMESPACE::Logger; +using ROCKSDB_NAMESPACE::Slice; + // A 'model' merge operator with uint64 addition semantics // Implemented as an AssociativeMergeOperator for simplicity and example. class UInt64AddOperator : public AssociativeMergeOperator { @@ -31,7 +34,7 @@ class UInt64AddOperator : public AssociativeMergeOperator { assert(new_value); new_value->clear(); - PutFixed64(new_value, orig_value + operand); + ROCKSDB_NAMESPACE::PutFixed64(new_value, orig_value + operand); return true; // Return true always since corruption will be treated as 0 } @@ -48,20 +51,20 @@ class UInt64AddOperator : public AssociativeMergeOperator { uint64_t result = 0; if (value.size() == sizeof(uint64_t)) { - result = DecodeFixed64(value.data()); + result = ROCKSDB_NAMESPACE::DecodeFixed64(value.data()); } else if (logger != nullptr) { // If value is corrupted, treat it as 0 - ROCKS_LOG_ERROR(logger, "uint64 value corruption, size: %" ROCKSDB_PRIszt - " > %" ROCKSDB_PRIszt, + ROCKS_LOG_ERROR(logger, + "uint64 value corruption, size: %" ROCKSDB_PRIszt + " > %" ROCKSDB_PRIszt, value.size(), sizeof(uint64_t)); } return result; } - }; -} +} // anonymous namespace namespace ROCKSDB_NAMESPACE { diff --git a/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.cc b/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.cc index aa57e5c36..054e24d3a 100644 --- a/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.cc +++ b/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.cc @@ -148,7 +148,7 @@ Status RangeTreeLockManager::TryLock(PessimisticTransaction* txn, // Wait callback that locktree library will call to inform us about // the lock waits that are in progress. -void wait_callback_for_locktree(void*, lock_wait_infos* infos) { +void wait_callback_for_locktree(void*, toku::lock_wait_infos* infos) { for (auto wait_info : *infos) { auto txn = (PessimisticTransaction*)wait_info.waiter; auto cf_id = (ColumnFamilyId)wait_info.ltree->get_dict_id().dictid; @@ -249,7 +249,8 @@ namespace { void UnrefLockTreeMapsCache(void* ptr) { // Called when a thread exits or a ThreadLocalPtr gets destroyed. auto lock_tree_map_cache = static_cast< - std::unordered_map>*>(ptr); + std::unordered_map>*>( + ptr); delete lock_tree_map_cache; } } // anonymous namespace @@ -299,8 +300,9 @@ std::vector RangeTreeLockManager::GetDeadlockInfoBuffer() { // @param buffer Escalation result: list of locks that this transaction now // owns in this lock tree. // @param void* Callback context -void RangeTreeLockManager::on_escalate(TXNID txnid, const locktree* lt, - const range_buffer& buffer, void*) { +void RangeTreeLockManager::on_escalate(TXNID txnid, const toku::locktree* lt, + const toku::range_buffer& buffer, + void*) { auto txn = (PessimisticTransaction*)txnid; ((RangeTreeLockTracker*)&txn->GetTrackedLocks())->ReplaceLocks(lt, buffer); } @@ -340,10 +342,11 @@ RangeLockManagerHandle::Counters RangeTreeLockManager::GetStatus() { return res; } -std::shared_ptr RangeTreeLockManager::MakeLockTreePtr(locktree* lt) { - locktree_manager* ltm = <m_; - return std::shared_ptr(lt, - [ltm](locktree* p) { ltm->release_lt(p); }); +std::shared_ptr RangeTreeLockManager::MakeLockTreePtr( + toku::locktree* lt) { + toku::locktree_manager* ltm = <m_; + return std::shared_ptr( + lt, [ltm](toku::locktree* p) { ltm->release_lt(p); }); } void RangeTreeLockManager::AddColumnFamily(const ColumnFamilyHandle* cfh) { @@ -398,7 +401,7 @@ void RangeTreeLockManager::RemoveColumnFamily(const ColumnFamilyHandle* cfh) { } } -std::shared_ptr RangeTreeLockManager::GetLockTreeForCF( +std::shared_ptr RangeTreeLockManager::GetLockTreeForCF( ColumnFamilyId column_family_id) { // First check thread-local cache if (ltree_lookup_cache_->Get() == nullptr) { diff --git a/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.h b/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.h index 5d55ded02..e7c150281 100644 --- a/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.h +++ b/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.h @@ -19,8 +19,6 @@ namespace ROCKSDB_NAMESPACE { -using namespace toku; - typedef DeadlockInfoBufferTempl RangeDeadlockInfoBuffer; // A Range Lock Manager that uses PerconaFT's locktree library @@ -91,7 +89,7 @@ class RangeTreeLockManager : public RangeLockManagerBase, } // Get the locktree which stores locks for the Column Family with given cf_id - std::shared_ptr GetLockTreeForCF(ColumnFamilyId cf_id); + std::shared_ptr GetLockTreeForCF(ColumnFamilyId cf_id); private: toku::locktree_manager ltm_; @@ -101,7 +99,7 @@ class RangeTreeLockManager : public RangeLockManagerBase, // Map from cf_id to locktree*. Can only be accessed while holding the // ltree_map_mutex_. Must use a custom deleter that calls ltm_.release_lt using LockTreeMap = - std::unordered_map>; + std::unordered_map>; LockTreeMap ltree_map_; InstrumentedMutex ltree_map_mutex_; @@ -112,18 +110,18 @@ class RangeTreeLockManager : public RangeLockManagerBase, RangeDeadlockInfoBuffer dlock_buffer_; - std::shared_ptr MakeLockTreePtr(locktree* lt); + std::shared_ptr MakeLockTreePtr(toku::locktree* lt); static int CompareDbtEndpoints(void* arg, const DBT* a_key, const DBT* b_key); // Callbacks - static int on_create(locktree*, void*) { return 0; /* no error */ } - static void on_destroy(locktree*) {} - static void on_escalate(TXNID txnid, const locktree* lt, - const range_buffer& buffer, void* extra); + static int on_create(toku::locktree*, void*) { return 0; /* no error */ } + static void on_destroy(toku::locktree*) {} + static void on_escalate(TXNID txnid, const toku::locktree* lt, + const toku::range_buffer& buffer, void* extra); }; void serialize_endpoint(const Endpoint& endp, std::string* buf); -void wait_callback_for_locktree(void* cdata, lock_wait_infos* infos); +void wait_callback_for_locktree(void* cdata, toku::lock_wait_infos* infos); } // namespace ROCKSDB_NAMESPACE #endif // OS_WIN