Remove using namespace (#9369)

Summary:
As title.
This is part of an fb-internal task.
First, remove all `using namespace` statements if applicable.
Next, utilize multiple build platforms and see if anything is broken.
Should anything become broken, fix the compilation errors with as little extra change as possible.

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

Test Plan:
internal build and make check
make clean && make static_lib && cd examples && make all

Reviewed By: pdillinger

Differential Revision: D33517260

Pulled By: riversand963

fbshipit-source-id: 3fc4ce6402a073421dfd9a9b2d1c79441dca7a40
This commit is contained in:
Yanqin Jin 2022-01-12 09:28:09 -08:00 committed by Facebook GitHub Bot
parent 21e71d1c73
commit 0376869f05
26 changed files with 270 additions and 173 deletions

View File

@ -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()) {

View File

@ -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));

View File

@ -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<ColumnFamilyDescriptor> 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()));

View File

@ -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);

View File

@ -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";

View File

@ -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<ColumnFamilyDescriptor> 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());

View File

@ -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";

View File

@ -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;
}

View File

@ -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.

View File

@ -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;

View File

@ -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::Status (ROCKSDB_NAMESPACE::Transaction::*)(
const ROCKSDB_NAMESPACE::ReadOptions&,
const ROCKSDB_NAMESPACE::Slice&, std::string*)>(
&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<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>&,
const std::vector<ROCKSDB_NAMESPACE::Slice>&, std::vector<std::string>*)>(
&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<ROCKSDB_NAMESPACE::Slice>&, std::vector<std::string>*)>(
&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::Status (ROCKSDB_NAMESPACE::Transaction::*)(
const ROCKSDB_NAMESPACE::ReadOptions&,
const ROCKSDB_NAMESPACE::Slice&, std::string*, bool, bool)>(
&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<ROCKSDB_NAMESPACE::ColumnFamilyHandle*>&,
const std::vector<ROCKSDB_NAMESPACE::Slice>&, std::vector<std::string>*)>(
&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<ROCKSDB_NAMESPACE::Slice>&, std::vector<std::string>*)>(
&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::Status (ROCKSDB_NAMESPACE::Transaction::*)(
const ROCKSDB_NAMESPACE::Slice&, const ROCKSDB_NAMESPACE::Slice&)>(
&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::Status (
ROCKSDB_NAMESPACE::Transaction::*)(const ROCKSDB_NAMESPACE::SliceParts&,
const ROCKSDB_NAMESPACE::SliceParts&)>(
&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::Status (ROCKSDB_NAMESPACE::Transaction::*)(
const ROCKSDB_NAMESPACE::Slice&, const ROCKSDB_NAMESPACE::Slice&)>(
&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<ROCKSDB_NAMESPACE::Transaction*>(jhandle);
FnWriteK fn_delete = std::bind<ROCKSDB_NAMESPACE::Status (
ROCKSDB_NAMESPACE::Transaction::*)(const ROCKSDB_NAMESPACE::Slice&)>(
&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<ROCKSDB_NAMESPACE::Transaction*>(jhandle);
FnWriteKParts fn_delete_parts = std::bind<ROCKSDB_NAMESPACE::Status (
ROCKSDB_NAMESPACE::Transaction::*)(const ROCKSDB_NAMESPACE::SliceParts&)>(
&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<ROCKSDB_NAMESPACE::Transaction*>(jhandle);
FnWriteK fn_single_delete = std::bind<ROCKSDB_NAMESPACE::Status (
ROCKSDB_NAMESPACE::Transaction::*)(const ROCKSDB_NAMESPACE::Slice&)>(
&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<ROCKSDB_NAMESPACE::Transaction*>(jhandle);
FnWriteKParts fn_single_delete_parts = std::bind<ROCKSDB_NAMESPACE::Status (
ROCKSDB_NAMESPACE::Transaction::*)(const ROCKSDB_NAMESPACE::SliceParts&)>(
&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::Status (ROCKSDB_NAMESPACE::Transaction::*)(
const ROCKSDB_NAMESPACE::Slice&, const ROCKSDB_NAMESPACE::Slice&)>(
&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::Status (
ROCKSDB_NAMESPACE::Transaction::*)(const ROCKSDB_NAMESPACE::SliceParts&,
const ROCKSDB_NAMESPACE::SliceParts&)>(
&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::Status (ROCKSDB_NAMESPACE::Transaction::*)(
const ROCKSDB_NAMESPACE::Slice&, const ROCKSDB_NAMESPACE::Slice&)>(
&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<ROCKSDB_NAMESPACE::Transaction*>(jhandle);
FnWriteK fn_delete_untracked = std::bind<ROCKSDB_NAMESPACE::Status (
ROCKSDB_NAMESPACE::Transaction::*)(const ROCKSDB_NAMESPACE::Slice&)>(
&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::Status (ROCKSDB_NAMESPACE::Transaction::*)(
const ROCKSDB_NAMESPACE::SliceParts&)>(
&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);
}

View File

@ -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;
}

View File

@ -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

View File

@ -144,8 +144,8 @@ uint64_t WinClock::NowMicros() {
li.QuadPart /= c_FtToMicroSec;
return li.QuadPart;
}
using namespace std::chrono;
return duration_cast<microseconds>(system_clock::now().time_since_epoch())
return std::chrono::duration_cast<std::chrono::microseconds>(
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<nanoseconds>(
high_resolution_clock::now().time_since_epoch())
return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::high_resolution_clock::now().time_since_epoch())
.count();
}

View File

@ -27,9 +27,9 @@
#ifdef ROCKSDB_WINDOWS_UTF8_FILENAMES
// utf8 <-> utf16
#include <string>
#include <locale>
#include <codecvt>
#include <locale>
#include <string>
#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<std::codecvt_utf8_utf16<wchar_t>,wchar_t> convert;
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, 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::microseconds>(
std::chrono::system_clock::now().time_since_epoch()));
microseconds usNow(
duration_cast<microseconds>(system_clock::now().time_since_epoch()));
seconds secNow(duration_cast<seconds>(usNow));
std::chrono::seconds secNow(
std::chrono::duration_cast<std::chrono::seconds>(usNow));
tv->tv_sec = static_cast<long>(secNow.count());
tv->tv_usec = static_cast<long>(usNow.count() -
duration_cast<microseconds>(secNow).count());
tv->tv_usec = static_cast<long>(
usNow.count() -
std::chrono::duration_cast<std::chrono::microseconds>(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<microseconds>(system_clock::now().time_since_epoch()));
microseconds relTimeUs =
(usAbsTime > usNow) ? (usAbsTime - usNow) : microseconds::zero();
std::chrono::microseconds usNow(
std::chrono::duration_cast<std::chrono::microseconds>(
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<std::mutex> 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();
}
@ -143,8 +143,7 @@ struct DIR {
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;

View File

@ -20,8 +20,6 @@
#include <unistd.h>
#endif
using namespace std::chrono;
namespace folly {
namespace detail {
@ -69,7 +67,7 @@ int nativeFutexWake(const void* addr, int count, uint32_t wakeMask) {
}
template <class Clock>
struct timespec timeSpecFromTimePoint(time_point<Clock> absTime) {
struct timespec timeSpecFromTimePoint(std::chrono::time_point<Clock> 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<Clock> absTime) {
// timespec-safe seconds and nanoseconds;
// chrono::{nano,}seconds are `long long int`
// whereas timespec uses smaller types
using time_t_seconds = duration<std::time_t, seconds::period>;
using long_nanos = duration<long int, nanoseconds::period>;
using time_t_seconds =
std::chrono::duration<std::time_t, std::chrono::seconds::period>;
using long_nanos =
std::chrono::duration<long int, std::chrono::nanoseconds::period>;
auto secs = duration_cast<time_t_seconds>(epoch);
auto nanos = duration_cast<long_nanos>(epoch - secs);
auto secs = std::chrono::duration_cast<time_t_seconds>(epoch);
auto nanos = std::chrono::duration_cast<long_nanos>(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 <typename F>
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<F, const Futex<std::atomic>>::value ||
@ -235,10 +233,9 @@ int futexWakeImpl(
}
FutexResult futexWaitImpl(
const Futex<std::atomic>* futex,
uint32_t expected,
system_clock::time_point const* absSystemTime,
steady_clock::time_point const* absSteadyTime,
const Futex<std::atomic>* 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<EmulatedFutexAtomic>* futex,
uint32_t expected,
system_clock::time_point const* absSystemTime,
steady_clock::time_point const* absSteadyTime,
const Futex<EmulatedFutexAtomic>* 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);

View File

@ -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;

View File

@ -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;

View File

@ -27,9 +27,6 @@ namespace {
}
}
using namespace v8;
Persistent<Function> DBWrapper::constructor;
DBWrapper::DBWrapper() {

View File

@ -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

View File

@ -7,8 +7,6 @@
#include <v8.h>
#include "db/_wrapper.h"
using namespace v8;
void InitAll(Handle<Object> exports) {
DBWrapper::Init(exports);
}

View File

@ -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<ZSTDCachedData> per_core_uncompr_;
CoreLocalArray<compression_cache::ZSTDCachedData> per_core_uncompr_;
};
CompressionContextCache::CompressionContextCache() : rep_(new Rep()) {}

View File

@ -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

View File

@ -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
ROCKS_LOG_ERROR(logger,
"uint64 value corruption, size: %" ROCKSDB_PRIszt
" > %" ROCKSDB_PRIszt,
value.size(), sizeof(uint64_t));
}
return result;
}
};
}
} // anonymous namespace
namespace ROCKSDB_NAMESPACE {

View File

@ -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<ColumnFamilyId, std::shared_ptr<locktree>>*>(ptr);
std::unordered_map<ColumnFamilyId, std::shared_ptr<toku::locktree>>*>(
ptr);
delete lock_tree_map_cache;
}
} // anonymous namespace
@ -299,8 +300,9 @@ std::vector<DeadlockPath> 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<locktree> RangeTreeLockManager::MakeLockTreePtr(locktree* lt) {
locktree_manager* ltm = &ltm_;
return std::shared_ptr<locktree>(lt,
[ltm](locktree* p) { ltm->release_lt(p); });
std::shared_ptr<toku::locktree> RangeTreeLockManager::MakeLockTreePtr(
toku::locktree* lt) {
toku::locktree_manager* ltm = &ltm_;
return std::shared_ptr<toku::locktree>(
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<locktree> RangeTreeLockManager::GetLockTreeForCF(
std::shared_ptr<toku::locktree> RangeTreeLockManager::GetLockTreeForCF(
ColumnFamilyId column_family_id) {
// First check thread-local cache
if (ltree_lookup_cache_->Get() == nullptr) {

View File

@ -19,8 +19,6 @@
namespace ROCKSDB_NAMESPACE {
using namespace toku;
typedef DeadlockInfoBufferTempl<RangeDeadlockPath> 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<locktree> GetLockTreeForCF(ColumnFamilyId cf_id);
std::shared_ptr<toku::locktree> 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<ColumnFamilyId, std::shared_ptr<locktree>>;
std::unordered_map<ColumnFamilyId, std::shared_ptr<toku::locktree>>;
LockTreeMap ltree_map_;
InstrumentedMutex ltree_map_mutex_;
@ -112,18 +110,18 @@ class RangeTreeLockManager : public RangeLockManagerBase,
RangeDeadlockInfoBuffer dlock_buffer_;
std::shared_ptr<locktree> MakeLockTreePtr(locktree* lt);
std::shared_ptr<toku::locktree> 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