mirror of https://github.com/facebook/rocksdb.git
Eliminate use of 'using namespace std'. Also remove a number of ADL references to std functions.
Summary: Reduce use of argument-dependent name lookup in RocksDB. Test Plan: 'make check' passed. Reviewers: andrewkr Reviewed By: andrewkr Subscribers: leveldb, andrewkr, dhruba Differential Revision: https://reviews.facebook.net/D58203
This commit is contained in:
parent
26adaad438
commit
2073cf3775
|
@ -6,8 +6,6 @@
|
|||
#include "db/auto_roll_logger.h"
|
||||
#include "util/mutexlock.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace rocksdb {
|
||||
|
||||
// -- AutoRollLogger
|
||||
|
@ -47,7 +45,8 @@ void AutoRollLogger::RollLogFile() {
|
|||
env_->RenameFile(log_fname_, old_fname);
|
||||
}
|
||||
|
||||
string AutoRollLogger::ValistToString(const char* format, va_list args) const {
|
||||
std::string AutoRollLogger::ValistToString(const char* format,
|
||||
va_list args) const {
|
||||
// Any log messages longer than 1024 will get truncated.
|
||||
// The user is responsible for chopping longer messages into multi line log
|
||||
static const int MAXBUFFERSIZE = 1024;
|
||||
|
@ -112,7 +111,7 @@ void AutoRollLogger::LogHeader(const char* format, va_list args) {
|
|||
// strings
|
||||
va_list tmp;
|
||||
va_copy(tmp, args);
|
||||
string data = ValistToString(format, tmp);
|
||||
std::string data = ValistToString(format, tmp);
|
||||
va_end(tmp);
|
||||
|
||||
MutexLock l(&mutex_);
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace rocksdb {
|
||||
|
||||
class AutoRollLoggerTest : public testing::Test {
|
||||
|
@ -40,23 +38,22 @@ class AutoRollLoggerTest : public testing::Test {
|
|||
Env::Default()->CreateDir(kTestDir);
|
||||
}
|
||||
|
||||
void RollLogFileBySizeTest(AutoRollLogger* logger,
|
||||
size_t log_max_size,
|
||||
const string& log_message);
|
||||
uint64_t RollLogFileByTimeTest(AutoRollLogger* logger,
|
||||
size_t time,
|
||||
const string& log_message);
|
||||
void RollLogFileBySizeTest(AutoRollLogger* logger, size_t log_max_size,
|
||||
const std::string& log_message);
|
||||
uint64_t RollLogFileByTimeTest(AutoRollLogger* logger, size_t time,
|
||||
const std::string& log_message);
|
||||
|
||||
static const string kSampleMessage;
|
||||
static const string kTestDir;
|
||||
static const string kLogFile;
|
||||
static const std::string kSampleMessage;
|
||||
static const std::string kTestDir;
|
||||
static const std::string kLogFile;
|
||||
static Env* env;
|
||||
};
|
||||
|
||||
const string AutoRollLoggerTest::kSampleMessage(
|
||||
const std::string AutoRollLoggerTest::kSampleMessage(
|
||||
"this is the message to be written to the log file!!");
|
||||
const string AutoRollLoggerTest::kTestDir(test::TmpDir() + "/db_log_test");
|
||||
const string AutoRollLoggerTest::kLogFile(test::TmpDir() + "/db_log_test/LOG");
|
||||
const std::string AutoRollLoggerTest::kTestDir(test::TmpDir() + "/db_log_test");
|
||||
const std::string AutoRollLoggerTest::kLogFile(test::TmpDir() +
|
||||
"/db_log_test/LOG");
|
||||
Env* AutoRollLoggerTest::env = Env::Default();
|
||||
|
||||
// In this test we only want to Log some simple log message with
|
||||
|
@ -86,7 +83,7 @@ void GetFileCreateTime(const std::string& fname, uint64_t* file_ctime) {
|
|||
|
||||
void AutoRollLoggerTest::RollLogFileBySizeTest(AutoRollLogger* logger,
|
||||
size_t log_max_size,
|
||||
const string& log_message) {
|
||||
const std::string& log_message) {
|
||||
logger->SetInfoLogLevel(InfoLogLevel::INFO_LEVEL);
|
||||
// measure the size of each message, which is supposed
|
||||
// to be equal or greater than log_message.size()
|
||||
|
@ -111,7 +108,7 @@ void AutoRollLoggerTest::RollLogFileBySizeTest(AutoRollLogger* logger,
|
|||
}
|
||||
|
||||
uint64_t AutoRollLoggerTest::RollLogFileByTimeTest(
|
||||
AutoRollLogger* logger, size_t time, const string& log_message) {
|
||||
AutoRollLogger* logger, size_t time, const std::string& log_message) {
|
||||
uint64_t expected_create_time;
|
||||
uint64_t actual_create_time;
|
||||
uint64_t total_log_size;
|
||||
|
@ -361,13 +358,13 @@ TEST_F(AutoRollLoggerTest, InfoLogLevel) {
|
|||
|
||||
// Test the logger Header function for roll over logs
|
||||
// We expect the new logs creates as roll over to carry the headers specified
|
||||
static std::vector<string> GetOldFileNames(const string& path) {
|
||||
std::vector<string> ret;
|
||||
static std::vector<std::string> GetOldFileNames(const std::string& path) {
|
||||
std::vector<std::string> ret;
|
||||
|
||||
const string dirname = path.substr(/*start=*/ 0, path.find_last_of("/"));
|
||||
const string fname = path.substr(path.find_last_of("/") + 1);
|
||||
const std::string dirname = path.substr(/*start=*/0, path.find_last_of("/"));
|
||||
const std::string fname = path.substr(path.find_last_of("/") + 1);
|
||||
|
||||
std::vector<string> children;
|
||||
std::vector<std::string> children;
|
||||
Env::Default()->GetChildren(dirname, &children);
|
||||
|
||||
// We know that the old log files are named [path]<something>
|
||||
|
@ -382,12 +379,13 @@ static std::vector<string> GetOldFileNames(const string& path) {
|
|||
}
|
||||
|
||||
// Return the number of lines where a given pattern was found in the file
|
||||
static size_t GetLinesCount(const string& fname, const string& pattern) {
|
||||
stringstream ssbuf;
|
||||
string line;
|
||||
static size_t GetLinesCount(const std::string& fname,
|
||||
const std::string& pattern) {
|
||||
std::stringstream ssbuf;
|
||||
std::string line;
|
||||
size_t count = 0;
|
||||
|
||||
ifstream inFile(fname.c_str());
|
||||
std::ifstream inFile(fname.c_str());
|
||||
ssbuf << inFile.rdbuf();
|
||||
|
||||
while (getline(ssbuf, line)) {
|
||||
|
@ -426,7 +424,7 @@ TEST_F(AutoRollLoggerTest, LogHeaderTest) {
|
|||
}
|
||||
}
|
||||
|
||||
const string newfname = logger.TEST_log_fname();
|
||||
const std::string newfname = logger.TEST_log_fname();
|
||||
|
||||
// Log enough data to cause a roll over
|
||||
int i = 0;
|
||||
|
@ -466,7 +464,7 @@ TEST_F(AutoRollLoggerTest, LogFileExistence) {
|
|||
[](char ch) { return ch == '/'; }, '\\');
|
||||
std::string deleteCmd = "if exist " + testDir + " rd /s /q " + testDir;
|
||||
#else
|
||||
string deleteCmd = "rm -rf " + kTestDir;
|
||||
std::string deleteCmd = "rm -rf " + kTestDir;
|
||||
#endif
|
||||
ASSERT_EQ(system(deleteCmd.c_str()), 0);
|
||||
options.max_log_file_size = 100 * 1024 * 1024;
|
||||
|
|
|
@ -447,7 +447,7 @@ TEST_F(ColumnFamilyTest, AddDrop) {
|
|||
|
||||
std::vector<std::string> families;
|
||||
ASSERT_OK(DB::ListColumnFamilies(db_options_, dbname_, &families));
|
||||
sort(families.begin(), families.end());
|
||||
std::sort(families.begin(), families.end());
|
||||
ASSERT_TRUE(families ==
|
||||
std::vector<std::string>({"default", "four", "three"}));
|
||||
}
|
||||
|
|
|
@ -909,9 +909,11 @@ void DBImpl::PurgeObsoleteFiles(const JobContext& state) {
|
|||
|
||||
// dedup state.candidate_files so we don't try to delete the same
|
||||
// file twice
|
||||
sort(candidate_files.begin(), candidate_files.end(), CompareCandidateFile);
|
||||
candidate_files.erase(unique(candidate_files.begin(), candidate_files.end()),
|
||||
candidate_files.end());
|
||||
std::sort(candidate_files.begin(), candidate_files.end(),
|
||||
CompareCandidateFile);
|
||||
candidate_files.erase(
|
||||
std::unique(candidate_files.begin(), candidate_files.end()),
|
||||
candidate_files.end());
|
||||
|
||||
std::vector<std::string> old_info_log_files;
|
||||
InfoLogPrefix info_log_prefix(!db_options_.db_log_dir.empty(), dbname_);
|
||||
|
|
|
@ -2681,7 +2681,7 @@ TEST_F(DBTest, GroupCommitTest) {
|
|||
for (int i = 0; i < kGCNumThreads * kGCNumKeys; ++i) {
|
||||
expected_db.push_back(ToString(i));
|
||||
}
|
||||
sort(expected_db.begin(), expected_db.end());
|
||||
std::sort(expected_db.begin(), expected_db.end());
|
||||
|
||||
Iterator* itr = db_->NewIterator(ReadOptions());
|
||||
itr->SeekToFirst();
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#define __STDC_FORMAT_MACROS
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "db/transaction_log_impl.h"
|
||||
#include <inttypes.h>
|
||||
#include "db/write_batch_internal.h"
|
||||
#include "util/file_reader_writer.h"
|
||||
|
||||
|
@ -250,7 +250,7 @@ void TransactionLogIteratorImpl::UpdateCurrentWriteBatch(const Slice& record) {
|
|||
// currentBatchSeq_ can only change here
|
||||
assert(currentLastSeq_ <= versions_->LastSequence());
|
||||
|
||||
currentBatch_ = move(batch);
|
||||
currentBatch_ = std::move(batch);
|
||||
isValid_ = true;
|
||||
currentStatus_ = Status::OK();
|
||||
}
|
||||
|
@ -262,10 +262,9 @@ Status TransactionLogIteratorImpl::OpenLogReader(const LogFile* logFile) {
|
|||
return s;
|
||||
}
|
||||
assert(file);
|
||||
currentLogReader_.reset(new log::Reader(options_->info_log,
|
||||
std::move(file), &reporter_,
|
||||
read_options_.verify_checksums_, 0,
|
||||
logFile->LogNumber()));
|
||||
currentLogReader_.reset(new log::Reader(
|
||||
options_->info_log, std::move(file), &reporter_,
|
||||
read_options_.verify_checksums_, 0, logFile->LogNumber()));
|
||||
return Status::OK();
|
||||
}
|
||||
} // namespace rocksdb
|
||||
|
|
|
@ -1552,11 +1552,11 @@ void VersionStorageInfo::GenerateLevel0NonOverlapping() {
|
|||
std::vector<FdWithKeyRange> level0_sorted_file(
|
||||
level_files_brief_[0].files,
|
||||
level_files_brief_[0].files + level_files_brief_[0].num_files);
|
||||
sort(level0_sorted_file.begin(), level0_sorted_file.end(),
|
||||
[this](const FdWithKeyRange & f1, const FdWithKeyRange & f2)->bool {
|
||||
return (internal_comparator_->Compare(f1.smallest_key, f2.smallest_key) <
|
||||
0);
|
||||
});
|
||||
std::sort(level0_sorted_file.begin(), level0_sorted_file.end(),
|
||||
[this](const FdWithKeyRange& f1, const FdWithKeyRange& f2) -> bool {
|
||||
return (internal_comparator_->Compare(f1.smallest_key,
|
||||
f2.smallest_key) < 0);
|
||||
});
|
||||
|
||||
for (size_t i = 1; i < level0_sorted_file.size(); ++i) {
|
||||
FdWithKeyRange& f = level0_sorted_file[i];
|
||||
|
|
|
@ -189,9 +189,8 @@ char* Decompress(const char* input_data, size_t input_length,
|
|||
|
||||
if (!success) {
|
||||
#ifdef _DEBUG
|
||||
std::cerr <<
|
||||
"XPRESS: Failed to create Decompressor LastError " <<
|
||||
GetLastError() << std::endl;
|
||||
std::cerr << "XPRESS: Failed to create Decompressor LastError "
|
||||
<< GetLastError() << std::endl;
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -215,9 +214,9 @@ char* Decompress(const char* input_data, size_t input_length,
|
|||
|
||||
if (lastError != ERROR_INSUFFICIENT_BUFFER) {
|
||||
#ifdef _DEBUG
|
||||
std::cerr <<
|
||||
"XPRESS: Failed to estimate decompressed buffer size LastError " <<
|
||||
lastError << std::endl;
|
||||
std::cerr
|
||||
<< "XPRESS: Failed to estimate decompressed buffer size LastError "
|
||||
<< lastError << std::endl;
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -266,5 +265,3 @@ char* Decompress(const char* input_data, size_t input_length,
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -2152,8 +2152,9 @@ class StressTest {
|
|||
// this is a reopen. just assert that existing column_family_names are
|
||||
// equivalent to what we remember
|
||||
auto sorted_cfn = column_family_names_;
|
||||
sort(sorted_cfn.begin(), sorted_cfn.end());
|
||||
sort(existing_column_families.begin(), existing_column_families.end());
|
||||
std::sort(sorted_cfn.begin(), sorted_cfn.end());
|
||||
std::sort(existing_column_families.begin(),
|
||||
existing_column_families.end());
|
||||
if (sorted_cfn != existing_column_families) {
|
||||
fprintf(stderr,
|
||||
"Expected column families differ from the existing:\n");
|
||||
|
|
697
tools/ldb_cmd.cc
697
tools/ldb_cmd.cc
File diff suppressed because it is too large
Load Diff
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <atomic>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "rocksdb/env.h"
|
||||
|
@ -13,9 +14,10 @@
|
|||
#include "util/testharness.h"
|
||||
#include "util/testutil.h"
|
||||
|
||||
namespace rocksdb {
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
using namespace std;
|
||||
namespace rocksdb {
|
||||
|
||||
class AutoVectorTest : public testing::Test {};
|
||||
const unsigned long kSize = 8;
|
||||
|
@ -197,8 +199,8 @@ TEST_F(AutoVectorTest, Iterators) {
|
|||
}
|
||||
|
||||
namespace {
|
||||
vector<string> GetTestKeys(size_t size) {
|
||||
vector<string> keys;
|
||||
std::vector<std::string> GetTestKeys(size_t size) {
|
||||
std::vector<std::string> keys;
|
||||
keys.resize(size);
|
||||
|
||||
int index = 0;
|
||||
|
@ -209,9 +211,9 @@ vector<string> GetTestKeys(size_t size) {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
template<class TVector>
|
||||
template <class TVector>
|
||||
void BenchmarkVectorCreationAndInsertion(
|
||||
string name, size_t ops, size_t item_size,
|
||||
std::string name, size_t ops, size_t item_size,
|
||||
const std::vector<typename TVector::value_type>& items) {
|
||||
auto env = Env::Default();
|
||||
|
||||
|
@ -231,7 +233,7 @@ void BenchmarkVectorCreationAndInsertion(
|
|||
}
|
||||
|
||||
template <class TVector>
|
||||
size_t BenchmarkSequenceAccess(string name, size_t ops, size_t elem_size) {
|
||||
size_t BenchmarkSequenceAccess(std::string name, size_t ops, size_t elem_size) {
|
||||
TVector v;
|
||||
for (const auto& item : GetTestKeys(elem_size)) {
|
||||
v.push_back(item);
|
||||
|
@ -255,9 +257,9 @@ size_t BenchmarkSequenceAccess(string name, size_t ops, size_t elem_size) {
|
|||
return total;
|
||||
}
|
||||
|
||||
// This test case only reports the performance between std::vector<string>
|
||||
// and autovector<string>. We chose string for comparison because in most
|
||||
// o our use cases we used std::vector<string>.
|
||||
// This test case only reports the performance between std::vector<std::string>
|
||||
// and autovector<std::string>. We chose string for comparison because in most
|
||||
// of our use cases we used std::vector<std::string>.
|
||||
TEST_F(AutoVectorTest, PerfBench) {
|
||||
// We run same operations for kOps times in order to get a more fair result.
|
||||
size_t kOps = 100000;
|
||||
|
@ -279,12 +281,10 @@ TEST_F(AutoVectorTest, PerfBench) {
|
|||
// pre-generated unique keys
|
||||
auto string_keys = GetTestKeys(kOps * 2 * kSize);
|
||||
for (auto insertions : { 0ul, 1ul, kSize / 2, kSize, 2 * kSize }) {
|
||||
BenchmarkVectorCreationAndInsertion<vector<string>>(
|
||||
"vector<string>", kOps, insertions, string_keys
|
||||
);
|
||||
BenchmarkVectorCreationAndInsertion<autovector<string, kSize>>(
|
||||
"autovector<string>", kOps, insertions, string_keys
|
||||
);
|
||||
BenchmarkVectorCreationAndInsertion<std::vector<std::string>>(
|
||||
"std::vector<std::string>", kOps, insertions, string_keys);
|
||||
BenchmarkVectorCreationAndInsertion<autovector<std::string, kSize>>(
|
||||
"autovector<std::string>", kOps, insertions, string_keys);
|
||||
cout << "-----------------------------------" << endl;
|
||||
}
|
||||
|
||||
|
@ -293,14 +293,13 @@ TEST_F(AutoVectorTest, PerfBench) {
|
|||
cout << "=====================================================" << endl;
|
||||
|
||||
// pre-generated unique keys
|
||||
vector<uint64_t> int_keys(kOps * 2 * kSize);
|
||||
std::vector<uint64_t> int_keys(kOps * 2 * kSize);
|
||||
for (size_t i = 0; i < kOps * 2 * kSize; ++i) {
|
||||
int_keys[i] = i;
|
||||
}
|
||||
for (auto insertions : { 0ul, 1ul, kSize / 2, kSize, 2 * kSize }) {
|
||||
BenchmarkVectorCreationAndInsertion<vector<uint64_t>>(
|
||||
"vector<uint64_t>", kOps, insertions, int_keys
|
||||
);
|
||||
BenchmarkVectorCreationAndInsertion<std::vector<uint64_t>>(
|
||||
"std::vector<uint64_t>", kOps, insertions, int_keys);
|
||||
BenchmarkVectorCreationAndInsertion<autovector<uint64_t, kSize>>(
|
||||
"autovector<uint64_t>", kOps, insertions, int_keys
|
||||
);
|
||||
|
@ -312,12 +311,10 @@ TEST_F(AutoVectorTest, PerfBench) {
|
|||
cout << "Sequence Access Test" << endl;
|
||||
cout << "=====================================================" << endl;
|
||||
for (auto elem_size : { kSize / 2, kSize, 2 * kSize }) {
|
||||
BenchmarkSequenceAccess<vector<string>>(
|
||||
"vector", kOps, elem_size
|
||||
);
|
||||
BenchmarkSequenceAccess<autovector<string, kSize>>(
|
||||
"autovector", kOps, elem_size
|
||||
);
|
||||
BenchmarkSequenceAccess<std::vector<std::string>>("std::vector", kOps,
|
||||
elem_size);
|
||||
BenchmarkSequenceAccess<autovector<std::string, kSize>>("autovector", kOps,
|
||||
elem_size);
|
||||
cout << "-----------------------------------" << endl;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -554,8 +554,8 @@ TEST_F(CacheTest, ApplyToAllCacheEntiresTest) {
|
|||
}
|
||||
cache_->ApplyToAllCacheEntries(callback, true);
|
||||
|
||||
sort(inserted.begin(), inserted.end());
|
||||
sort(callback_state.begin(), callback_state.end());
|
||||
std::sort(inserted.begin(), inserted.end());
|
||||
std::sort(callback_state.begin(), callback_state.end());
|
||||
ASSERT_TRUE(inserted == callback_state);
|
||||
}
|
||||
|
||||
|
|
|
@ -471,7 +471,7 @@ Status HdfsEnv::GetChildren(const std::string& path,
|
|||
if (numEntries >= 0) {
|
||||
for(int i = 0; i < numEntries; i++) {
|
||||
char* pathname = pHdfsFileInfo[i].mName;
|
||||
char* filename = rindex(pathname, '/');
|
||||
char* filename = std::rindex(pathname, '/');
|
||||
if (filename != nullptr) {
|
||||
result->push_back(filename+1);
|
||||
}
|
||||
|
|
|
@ -197,8 +197,8 @@ class TestEnv : public EnvWrapper {
|
|||
|
||||
void AssertWrittenFiles(std::vector<std::string>& should_have_written) {
|
||||
MutexLock l(&mutex_);
|
||||
sort(should_have_written.begin(), should_have_written.end());
|
||||
sort(written_files_.begin(), written_files_.end());
|
||||
std::sort(should_have_written.begin(), should_have_written.end());
|
||||
std::sort(written_files_.begin(), written_files_.end());
|
||||
ASSERT_TRUE(written_files_ == should_have_written);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,13 +25,12 @@
|
|||
#include "util/random.h"
|
||||
|
||||
using namespace rocksdb;
|
||||
using namespace std;
|
||||
|
||||
namespace rocksdb {
|
||||
|
||||
class RedisListsTest : public testing::Test {
|
||||
public:
|
||||
static const string kDefaultDbName;
|
||||
static const std::string kDefaultDbName;
|
||||
static Options options;
|
||||
|
||||
RedisListsTest() {
|
||||
|
@ -39,7 +38,7 @@ class RedisListsTest : public testing::Test {
|
|||
}
|
||||
};
|
||||
|
||||
const string RedisListsTest::kDefaultDbName =
|
||||
const std::string RedisListsTest::kDefaultDbName =
|
||||
test::TmpDir() + "/redis_lists_test";
|
||||
Options RedisListsTest::options = Options();
|
||||
|
||||
|
@ -60,7 +59,7 @@ void AssertListEq(const std::vector<std::string>& result,
|
|||
TEST_F(RedisListsTest, SimpleTest) {
|
||||
RedisLists redis(kDefaultDbName, options, true); // Destructive
|
||||
|
||||
string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
std::string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
|
||||
// Simple PushRight (should return the new length each time)
|
||||
ASSERT_EQ(redis.PushRight("k1", "v1"), 1);
|
||||
|
@ -89,7 +88,7 @@ TEST_F(RedisListsTest, SimpleTest) {
|
|||
TEST_F(RedisListsTest, SimpleTest2) {
|
||||
RedisLists redis(kDefaultDbName, options, true); // Destructive
|
||||
|
||||
string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
std::string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
|
||||
// Simple PushRight
|
||||
ASSERT_EQ(redis.PushLeft("k1", "v3"), 1);
|
||||
|
@ -118,7 +117,7 @@ TEST_F(RedisListsTest, SimpleTest2) {
|
|||
TEST_F(RedisListsTest, IndexTest) {
|
||||
RedisLists redis(kDefaultDbName, options, true); // Destructive
|
||||
|
||||
string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
std::string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
|
||||
// Empty Index check (return empty and should not crash or edit tempv)
|
||||
tempv = "yo";
|
||||
|
@ -177,7 +176,7 @@ TEST_F(RedisListsTest, IndexTest) {
|
|||
TEST_F(RedisListsTest, RangeTest) {
|
||||
RedisLists redis(kDefaultDbName, options, true); // Destructive
|
||||
|
||||
string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
std::string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
|
||||
// Simple Pushes (will yield: [v6, v4, v4, v1, v2, v3])
|
||||
redis.PushRight("k1", "v1");
|
||||
|
@ -260,7 +259,7 @@ TEST_F(RedisListsTest, RangeTest) {
|
|||
TEST_F(RedisListsTest, InsertTest) {
|
||||
RedisLists redis(kDefaultDbName, options, true);
|
||||
|
||||
string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
std::string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
|
||||
// Insert on empty list (return 0, and do not crash)
|
||||
ASSERT_EQ(redis.InsertBefore("k1", "non-exist", "a"), 0);
|
||||
|
@ -344,7 +343,7 @@ TEST_F(RedisListsTest, InsertTest) {
|
|||
TEST_F(RedisListsTest, SetTest) {
|
||||
RedisLists redis(kDefaultDbName, options, true);
|
||||
|
||||
string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
std::string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
|
||||
// Set on empty list (return false, and do not crash)
|
||||
ASSERT_EQ(redis.Set("k1", 7, "a"), false);
|
||||
|
@ -440,7 +439,7 @@ TEST_F(RedisListsTest, SetTest) {
|
|||
TEST_F(RedisListsTest, InsertPushSetTest) {
|
||||
RedisLists redis(kDefaultDbName, options, true); // Destructive
|
||||
|
||||
string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
std::string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
|
||||
// A series of pushes and insertions
|
||||
// Will result in [newbegin, z, a, aftera, x, newend]
|
||||
|
@ -532,7 +531,7 @@ TEST_F(RedisListsTest, InsertPushSetTest) {
|
|||
TEST_F(RedisListsTest, TrimPopTest) {
|
||||
RedisLists redis(kDefaultDbName, options, true); // Destructive
|
||||
|
||||
string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
std::string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
|
||||
// A series of pushes and insertions
|
||||
// Will result in [newbegin, z, a, aftera, x, newend]
|
||||
|
@ -602,7 +601,7 @@ TEST_F(RedisListsTest, TrimPopTest) {
|
|||
TEST_F(RedisListsTest, RemoveTest) {
|
||||
RedisLists redis(kDefaultDbName, options, true); // Destructive
|
||||
|
||||
string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
std::string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
|
||||
// A series of pushes and insertions
|
||||
// Will result in [newbegin, z, a, aftera, x, newend, a, a]
|
||||
|
@ -691,7 +690,7 @@ TEST_F(RedisListsTest, RemoveTest) {
|
|||
|
||||
// Test Multiple keys and Persistence
|
||||
TEST_F(RedisListsTest, PersistenceMultiKeyTest) {
|
||||
string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
std::string tempv; // Used below for all Index(), PopRight(), PopLeft()
|
||||
|
||||
// Block one: populate a single key in the database
|
||||
{
|
||||
|
@ -768,12 +767,12 @@ int manual_redis_test(bool destructive){
|
|||
|
||||
std::string command;
|
||||
while(true) {
|
||||
cin >> command;
|
||||
std::cin >> command;
|
||||
MakeUpper(&command);
|
||||
|
||||
if (command == "LINSERT") {
|
||||
std::string k, t, p, v;
|
||||
cin >> k >> t >> p >> v;
|
||||
std::cin >> k >> t >> p >> v;
|
||||
MakeUpper(&t);
|
||||
if (t=="BEFORE") {
|
||||
std::cout << redis.InsertBefore(k, p, v) << std::endl;
|
||||
|
@ -791,13 +790,13 @@ int manual_redis_test(bool destructive){
|
|||
} else if (command == "LPOP") {
|
||||
std::string k;
|
||||
std::cin >> k;
|
||||
string res;
|
||||
std::string res;
|
||||
redis.PopLeft(k, &res);
|
||||
std::cout << res << std::endl;
|
||||
} else if (command == "RPOP") {
|
||||
std::string k;
|
||||
std::cin >> k;
|
||||
string res;
|
||||
std::string res;
|
||||
redis.PopRight(k, &res);
|
||||
std::cout << res << std::endl;
|
||||
} else if (command == "LREM") {
|
||||
|
@ -829,18 +828,18 @@ int manual_redis_test(bool destructive){
|
|||
std::string k;
|
||||
int idx;
|
||||
std::string v;
|
||||
cin >> k >> idx >> v;
|
||||
std::cin >> k >> idx >> v;
|
||||
redis.Set(k, idx, v);
|
||||
} else if (command == "LINDEX") {
|
||||
std::string k;
|
||||
int idx;
|
||||
std::cin >> k >> idx;
|
||||
string res;
|
||||
std::string res;
|
||||
redis.Index(k, idx, &res);
|
||||
std::cout << res << std::endl;
|
||||
} else if (command == "PRINT") { // Added by Deon
|
||||
std::string k;
|
||||
cin >> k;
|
||||
std::cin >> k;
|
||||
redis.Print(k);
|
||||
} else if (command == "QUIT") {
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue