Remove own ToString() (#9955)

Summary:
ToString() is created as some platform doesn't support std::to_string(). However, we've already used std::to_string() by mistake for 16 months (in db/db_info_dumper.cc). This commit just remove ToString().

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

Test Plan: Watch CI tests

Reviewed By: riversand963

Differential Revision: D36176799

fbshipit-source-id: bdb6dcd0e3a3ab96a1ac810f5d0188f684064471
This commit is contained in:
sdong 2022-05-06 13:03:58 -07:00 committed by Facebook GitHub Bot
parent 62d84e2a2b
commit 736a7b5433
125 changed files with 854 additions and 851 deletions

28
cache/cache_test.cc vendored
View File

@ -193,7 +193,7 @@ TEST_P(CacheTest, UsageTest) {
// make sure the cache will be overloaded // make sure the cache will be overloaded
for (uint64_t i = 1; i < kCapacity; ++i) { for (uint64_t i = 1; i < kCapacity; ++i) {
auto key = ToString(i); auto key = std::to_string(i);
ASSERT_OK(cache->Insert(key, reinterpret_cast<void*>(value), key.size() + 5, ASSERT_OK(cache->Insert(key, reinterpret_cast<void*>(value), key.size() + 5,
dumbDeleter)); dumbDeleter));
ASSERT_OK(precise_cache->Insert(key, reinterpret_cast<void*>(value), ASSERT_OK(precise_cache->Insert(key, reinterpret_cast<void*>(value),
@ -265,7 +265,7 @@ TEST_P(CacheTest, PinnedUsageTest) {
// check that overloading the cache does not change the pinned usage // check that overloading the cache does not change the pinned usage
for (uint64_t i = 1; i < 2 * kCapacity; ++i) { for (uint64_t i = 1; i < 2 * kCapacity; ++i) {
auto key = ToString(i); auto key = std::to_string(i);
ASSERT_OK(cache->Insert(key, reinterpret_cast<void*>(value), key.size() + 5, ASSERT_OK(cache->Insert(key, reinterpret_cast<void*>(value), key.size() + 5,
dumbDeleter)); dumbDeleter));
ASSERT_OK(precise_cache->Insert(key, reinterpret_cast<void*>(value), ASSERT_OK(precise_cache->Insert(key, reinterpret_cast<void*>(value),
@ -585,7 +585,7 @@ TEST_P(CacheTest, SetCapacity) {
std::vector<Cache::Handle*> handles(10); std::vector<Cache::Handle*> handles(10);
// Insert 5 entries, but not releasing. // Insert 5 entries, but not releasing.
for (size_t i = 0; i < 5; i++) { for (size_t i = 0; i < 5; i++) {
std::string key = ToString(i+1); std::string key = std::to_string(i + 1);
Status s = cache->Insert(key, new Value(i + 1), 1, &deleter, &handles[i]); Status s = cache->Insert(key, new Value(i + 1), 1, &deleter, &handles[i]);
ASSERT_TRUE(s.ok()); ASSERT_TRUE(s.ok());
} }
@ -600,7 +600,7 @@ TEST_P(CacheTest, SetCapacity) {
// then decrease capacity to 7, final capacity should be 7 // then decrease capacity to 7, final capacity should be 7
// and usage should be 7 // and usage should be 7
for (size_t i = 5; i < 10; i++) { for (size_t i = 5; i < 10; i++) {
std::string key = ToString(i+1); std::string key = std::to_string(i + 1);
Status s = cache->Insert(key, new Value(i + 1), 1, &deleter, &handles[i]); Status s = cache->Insert(key, new Value(i + 1), 1, &deleter, &handles[i]);
ASSERT_TRUE(s.ok()); ASSERT_TRUE(s.ok());
} }
@ -631,7 +631,7 @@ TEST_P(LRUCacheTest, SetStrictCapacityLimit) {
std::vector<Cache::Handle*> handles(10); std::vector<Cache::Handle*> handles(10);
Status s; Status s;
for (size_t i = 0; i < 10; i++) { for (size_t i = 0; i < 10; i++) {
std::string key = ToString(i + 1); std::string key = std::to_string(i + 1);
s = cache->Insert(key, new Value(i + 1), 1, &deleter, &handles[i]); s = cache->Insert(key, new Value(i + 1), 1, &deleter, &handles[i]);
ASSERT_OK(s); ASSERT_OK(s);
ASSERT_NE(nullptr, handles[i]); ASSERT_NE(nullptr, handles[i]);
@ -655,7 +655,7 @@ TEST_P(LRUCacheTest, SetStrictCapacityLimit) {
// test3: init with flag being true. // test3: init with flag being true.
std::shared_ptr<Cache> cache2 = NewCache(5, 0, true); std::shared_ptr<Cache> cache2 = NewCache(5, 0, true);
for (size_t i = 0; i < 5; i++) { for (size_t i = 0; i < 5; i++) {
std::string key = ToString(i + 1); std::string key = std::to_string(i + 1);
s = cache2->Insert(key, new Value(i + 1), 1, &deleter, &handles[i]); s = cache2->Insert(key, new Value(i + 1), 1, &deleter, &handles[i]);
ASSERT_OK(s); ASSERT_OK(s);
ASSERT_NE(nullptr, handles[i]); ASSERT_NE(nullptr, handles[i]);
@ -685,14 +685,14 @@ TEST_P(CacheTest, OverCapacity) {
// Insert n+1 entries, but not releasing. // Insert n+1 entries, but not releasing.
for (size_t i = 0; i < n + 1; i++) { for (size_t i = 0; i < n + 1; i++) {
std::string key = ToString(i+1); std::string key = std::to_string(i + 1);
Status s = cache->Insert(key, new Value(i + 1), 1, &deleter, &handles[i]); Status s = cache->Insert(key, new Value(i + 1), 1, &deleter, &handles[i]);
ASSERT_TRUE(s.ok()); ASSERT_TRUE(s.ok());
} }
// Guess what's in the cache now? // Guess what's in the cache now?
for (size_t i = 0; i < n + 1; i++) { for (size_t i = 0; i < n + 1; i++) {
std::string key = ToString(i+1); std::string key = std::to_string(i + 1);
auto h = cache->Lookup(key); auto h = cache->Lookup(key);
ASSERT_TRUE(h != nullptr); ASSERT_TRUE(h != nullptr);
if (h) cache->Release(h); if (h) cache->Release(h);
@ -713,7 +713,7 @@ TEST_P(CacheTest, OverCapacity) {
// This is consistent with the LRU policy since the element 0 // This is consistent with the LRU policy since the element 0
// was released first // was released first
for (size_t i = 0; i < n + 1; i++) { for (size_t i = 0; i < n + 1; i++) {
std::string key = ToString(i+1); std::string key = std::to_string(i + 1);
auto h = cache->Lookup(key); auto h = cache->Lookup(key);
if (h) { if (h) {
ASSERT_NE(i, 0U); ASSERT_NE(i, 0U);
@ -754,9 +754,9 @@ TEST_P(CacheTest, ApplyToAllEntriesTest) {
std::vector<std::string> callback_state; std::vector<std::string> callback_state;
const auto callback = [&](const Slice& key, void* value, size_t charge, const auto callback = [&](const Slice& key, void* value, size_t charge,
Cache::DeleterFn deleter) { Cache::DeleterFn deleter) {
callback_state.push_back(ToString(DecodeKey(key)) + "," + callback_state.push_back(std::to_string(DecodeKey(key)) + "," +
ToString(DecodeValue(value)) + "," + std::to_string(DecodeValue(value)) + "," +
ToString(charge)); std::to_string(charge));
assert(deleter == &CacheTest::Deleter); assert(deleter == &CacheTest::Deleter);
}; };
@ -765,8 +765,8 @@ TEST_P(CacheTest, ApplyToAllEntriesTest) {
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
Insert(i, i * 2, i + 1); Insert(i, i * 2, i + 1);
inserted.push_back(ToString(i) + "," + ToString(i * 2) + "," + inserted.push_back(std::to_string(i) + "," + std::to_string(i * 2) + "," +
ToString(i + 1)); std::to_string(i + 1));
} }
cache_->ApplyToAllEntries(callback, /*opts*/ {}); cache_->ApplyToAllEntries(callback, /*opts*/ {});

View File

@ -23,7 +23,7 @@ Status ArenaWrappedDBIter::GetProperty(std::string prop_name,
if (prop_name == "rocksdb.iterator.super-version-number") { if (prop_name == "rocksdb.iterator.super-version-number") {
// First try to pass the value returned from inner iterator. // First try to pass the value returned from inner iterator.
if (!db_iter_->GetProperty(prop_name, prop).ok()) { if (!db_iter_->GetProperty(prop_name, prop).ok()) {
*prop = ToString(sv_number_); *prop = std::to_string(sv_number_);
} }
return Status::OK(); return Status::OK();
} }

View File

@ -96,9 +96,9 @@ class BlobIndex {
assert(slice.size() > 0); assert(slice.size() > 0);
type_ = static_cast<Type>(*slice.data()); type_ = static_cast<Type>(*slice.data());
if (type_ >= Type::kUnknown) { if (type_ >= Type::kUnknown) {
return Status::Corruption( return Status::Corruption(kErrorMessage,
kErrorMessage, "Unknown blob index type: " +
"Unknown blob index type: " + ToString(static_cast<char>(type_))); std::to_string(static_cast<char>(type_)));
} }
slice = Slice(slice.data() + 1, slice.size() - 1); slice = Slice(slice.data() + 1, slice.size() - 1);
if (HasTTL()) { if (HasTTL()) {

View File

@ -153,11 +153,11 @@ TEST_F(DBBlobIndexTest, Write) {
key_values.reserve(num_key_values); key_values.reserve(num_key_values);
for (size_t i = 1; i <= num_key_values; ++i) { for (size_t i = 1; i <= num_key_values; ++i) {
std::string key = "key" + ToString(i); std::string key = "key" + std::to_string(i);
std::string blob_index; std::string blob_index;
BlobIndex::EncodeInlinedTTL(&blob_index, /* expiration */ 9876543210, BlobIndex::EncodeInlinedTTL(&blob_index, /* expiration */ 9876543210,
"blob" + ToString(i)); "blob" + std::to_string(i));
key_values.emplace_back(std::move(key), std::move(blob_index)); key_values.emplace_back(std::move(key), std::move(blob_index));
} }
@ -230,7 +230,7 @@ TEST_F(DBBlobIndexTest, Updated) {
DestroyAndReopen(GetTestOptions()); DestroyAndReopen(GetTestOptions());
WriteBatch batch; WriteBatch batch;
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
ASSERT_OK(PutBlobIndex(&batch, "key" + ToString(i), blob_index)); ASSERT_OK(PutBlobIndex(&batch, "key" + std::to_string(i), blob_index));
} }
ASSERT_OK(Write(&batch)); ASSERT_OK(Write(&batch));
// Avoid blob values from being purged. // Avoid blob values from being purged.
@ -248,7 +248,7 @@ TEST_F(DBBlobIndexTest, Updated) {
ASSERT_OK(dbfull()->DeleteRange(WriteOptions(), cfh(), "key6", "key9")); ASSERT_OK(dbfull()->DeleteRange(WriteOptions(), cfh(), "key6", "key9"));
MoveDataTo(tier); MoveDataTo(tier);
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
ASSERT_EQ(blob_index, GetBlobIndex("key" + ToString(i), snapshot)); ASSERT_EQ(blob_index, GetBlobIndex("key" + std::to_string(i), snapshot));
} }
ASSERT_EQ("new_value", Get("key1")); ASSERT_EQ("new_value", Get("key1"));
if (tier <= kImmutableMemtables) { if (tier <= kImmutableMemtables) {
@ -260,7 +260,7 @@ TEST_F(DBBlobIndexTest, Updated) {
ASSERT_EQ("NOT_FOUND", Get("key4")); ASSERT_EQ("NOT_FOUND", Get("key4"));
ASSERT_EQ("a,b,c", GetImpl("key5")); ASSERT_EQ("a,b,c", GetImpl("key5"));
for (int i = 6; i < 9; i++) { for (int i = 6; i < 9; i++) {
ASSERT_EQ("NOT_FOUND", Get("key" + ToString(i))); ASSERT_EQ("NOT_FOUND", Get("key" + std::to_string(i)));
} }
ASSERT_EQ(blob_index, GetBlobIndex("key9")); ASSERT_EQ(blob_index, GetBlobIndex("key9"));
dbfull()->ReleaseSnapshot(snapshot); dbfull()->ReleaseSnapshot(snapshot);
@ -301,7 +301,7 @@ TEST_F(DBBlobIndexTest, Iterate) {
}; };
auto get_value = [&](int index, int version) { auto get_value = [&](int index, int version) {
return get_key(index) + "_value" + ToString(version); return get_key(index) + "_value" + std::to_string(version);
}; };
auto check_iterator = [&](Iterator* iterator, Status::Code expected_status, auto check_iterator = [&](Iterator* iterator, Status::Code expected_status,
@ -501,7 +501,7 @@ TEST_F(DBBlobIndexTest, IntegratedBlobIterate) {
auto get_key = [](size_t index) { return ("key" + std::to_string(index)); }; auto get_key = [](size_t index) { return ("key" + std::to_string(index)); };
auto get_value = [&](size_t index, size_t version) { auto get_value = [&](size_t index, size_t version) {
return get_key(index) + "_value" + ToString(version); return get_key(index) + "_value" + std::to_string(version);
}; };
auto check_iterator = [&](Iterator* iterator, Status expected_status, auto check_iterator = [&](Iterator* iterator, Status expected_status,

View File

@ -383,7 +383,7 @@ class ColumnFamilyTestBase : public testing::Test {
int NumTableFilesAtLevel(int level, int cf) { int NumTableFilesAtLevel(int level, int cf) {
return GetProperty(cf, return GetProperty(cf,
"rocksdb.num-files-at-level" + ToString(level)); "rocksdb.num-files-at-level" + std::to_string(level));
} }
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
@ -783,7 +783,7 @@ TEST_P(ColumnFamilyTest, BulkAddDrop) {
std::vector<std::string> cf_names; std::vector<std::string> cf_names;
std::vector<ColumnFamilyHandle*> cf_handles; std::vector<ColumnFamilyHandle*> cf_handles;
for (int i = 1; i <= kNumCF; i++) { for (int i = 1; i <= kNumCF; i++) {
cf_names.push_back("cf1-" + ToString(i)); cf_names.push_back("cf1-" + std::to_string(i));
} }
ASSERT_OK(db_->CreateColumnFamilies(cf_options, cf_names, &cf_handles)); ASSERT_OK(db_->CreateColumnFamilies(cf_options, cf_names, &cf_handles));
for (int i = 1; i <= kNumCF; i++) { for (int i = 1; i <= kNumCF; i++) {
@ -796,7 +796,8 @@ TEST_P(ColumnFamilyTest, BulkAddDrop) {
} }
cf_handles.clear(); cf_handles.clear();
for (int i = 1; i <= kNumCF; i++) { for (int i = 1; i <= kNumCF; i++) {
cf_descriptors.emplace_back("cf2-" + ToString(i), ColumnFamilyOptions()); cf_descriptors.emplace_back("cf2-" + std::to_string(i),
ColumnFamilyOptions());
} }
ASSERT_OK(db_->CreateColumnFamilies(cf_descriptors, &cf_handles)); ASSERT_OK(db_->CreateColumnFamilies(cf_descriptors, &cf_handles));
for (int i = 1; i <= kNumCF; i++) { for (int i = 1; i <= kNumCF; i++) {
@ -820,7 +821,7 @@ TEST_P(ColumnFamilyTest, DropTest) {
Open({"default"}); Open({"default"});
CreateColumnFamiliesAndReopen({"pikachu"}); CreateColumnFamiliesAndReopen({"pikachu"});
for (int i = 0; i < 100; ++i) { for (int i = 0; i < 100; ++i) {
ASSERT_OK(Put(1, ToString(i), "bar" + ToString(i))); ASSERT_OK(Put(1, std::to_string(i), "bar" + std::to_string(i)));
} }
ASSERT_OK(Flush(1)); ASSERT_OK(Flush(1));
@ -1344,7 +1345,7 @@ TEST_P(ColumnFamilyTest, DifferentCompactionStyles) {
PutRandomData(1, 10, 12000); PutRandomData(1, 10, 12000);
PutRandomData(1, 1, 10); PutRandomData(1, 1, 10);
WaitForFlush(1); WaitForFlush(1);
AssertFilesPerLevel(ToString(i + 1), 1); AssertFilesPerLevel(std::to_string(i + 1), 1);
} }
// SETUP column family "two" -- level style with 4 levels // SETUP column family "two" -- level style with 4 levels
@ -1352,7 +1353,7 @@ TEST_P(ColumnFamilyTest, DifferentCompactionStyles) {
PutRandomData(2, 10, 12000); PutRandomData(2, 10, 12000);
PutRandomData(2, 1, 10); PutRandomData(2, 1, 10);
WaitForFlush(2); WaitForFlush(2);
AssertFilesPerLevel(ToString(i + 1), 2); AssertFilesPerLevel(std::to_string(i + 1), 2);
} }
// TRIGGER compaction "one" // TRIGGER compaction "one"
@ -1416,7 +1417,7 @@ TEST_P(ColumnFamilyTest, MultipleManualCompactions) {
PutRandomData(1, 10, 12000, true); PutRandomData(1, 10, 12000, true);
PutRandomData(1, 1, 10, true); PutRandomData(1, 1, 10, true);
WaitForFlush(1); WaitForFlush(1);
AssertFilesPerLevel(ToString(i + 1), 1); AssertFilesPerLevel(std::to_string(i + 1), 1);
} }
bool cf_1_1 = true; bool cf_1_1 = true;
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency( ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
@ -1446,7 +1447,7 @@ TEST_P(ColumnFamilyTest, MultipleManualCompactions) {
PutRandomData(2, 10, 12000); PutRandomData(2, 10, 12000);
PutRandomData(2, 1, 10); PutRandomData(2, 1, 10);
WaitForFlush(2); WaitForFlush(2);
AssertFilesPerLevel(ToString(i + 1), 2); AssertFilesPerLevel(std::to_string(i + 1), 2);
} }
threads.emplace_back([&] { threads.emplace_back([&] {
TEST_SYNC_POINT("ColumnFamilyTest::MultiManual:1"); TEST_SYNC_POINT("ColumnFamilyTest::MultiManual:1");
@ -1533,7 +1534,7 @@ TEST_P(ColumnFamilyTest, AutomaticAndManualCompactions) {
PutRandomData(1, 10, 12000, true); PutRandomData(1, 10, 12000, true);
PutRandomData(1, 1, 10, true); PutRandomData(1, 1, 10, true);
WaitForFlush(1); WaitForFlush(1);
AssertFilesPerLevel(ToString(i + 1), 1); AssertFilesPerLevel(std::to_string(i + 1), 1);
} }
TEST_SYNC_POINT("ColumnFamilyTest::AutoManual:1"); TEST_SYNC_POINT("ColumnFamilyTest::AutoManual:1");
@ -1543,7 +1544,7 @@ TEST_P(ColumnFamilyTest, AutomaticAndManualCompactions) {
PutRandomData(2, 10, 12000); PutRandomData(2, 10, 12000);
PutRandomData(2, 1, 10); PutRandomData(2, 1, 10);
WaitForFlush(2); WaitForFlush(2);
AssertFilesPerLevel(ToString(i + 1), 2); AssertFilesPerLevel(std::to_string(i + 1), 2);
} }
ROCKSDB_NAMESPACE::port::Thread threads([&] { ROCKSDB_NAMESPACE::port::Thread threads([&] {
CompactRangeOptions compact_options; CompactRangeOptions compact_options;
@ -1615,7 +1616,7 @@ TEST_P(ColumnFamilyTest, ManualAndAutomaticCompactions) {
PutRandomData(1, 10, 12000, true); PutRandomData(1, 10, 12000, true);
PutRandomData(1, 1, 10, true); PutRandomData(1, 1, 10, true);
WaitForFlush(1); WaitForFlush(1);
AssertFilesPerLevel(ToString(i + 1), 1); AssertFilesPerLevel(std::to_string(i + 1), 1);
} }
bool cf_1_1 = true; bool cf_1_1 = true;
bool cf_1_2 = true; bool cf_1_2 = true;
@ -1650,7 +1651,7 @@ TEST_P(ColumnFamilyTest, ManualAndAutomaticCompactions) {
PutRandomData(2, 10, 12000); PutRandomData(2, 10, 12000);
PutRandomData(2, 1, 10); PutRandomData(2, 1, 10);
WaitForFlush(2); WaitForFlush(2);
AssertFilesPerLevel(ToString(i + 1), 2); AssertFilesPerLevel(std::to_string(i + 1), 2);
} }
TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:5"); TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:5");
threads.join(); threads.join();
@ -1709,7 +1710,7 @@ TEST_P(ColumnFamilyTest, SameCFManualManualCompactions) {
PutRandomData(1, 10, 12000, true); PutRandomData(1, 10, 12000, true);
PutRandomData(1, 1, 10, true); PutRandomData(1, 1, 10, true);
WaitForFlush(1); WaitForFlush(1);
AssertFilesPerLevel(ToString(i + 1), 1); AssertFilesPerLevel(std::to_string(i + 1), 1);
} }
bool cf_1_1 = true; bool cf_1_1 = true;
bool cf_1_2 = true; bool cf_1_2 = true;
@ -1748,8 +1749,8 @@ TEST_P(ColumnFamilyTest, SameCFManualManualCompactions) {
PutRandomData(1, 10, 12000, true); PutRandomData(1, 10, 12000, true);
PutRandomData(1, 1, 10, true); PutRandomData(1, 1, 10, true);
WaitForFlush(1); WaitForFlush(1);
AssertFilesPerLevel(ToString(one.level0_file_num_compaction_trigger + i), AssertFilesPerLevel(
1); std::to_string(one.level0_file_num_compaction_trigger + i), 1);
} }
ROCKSDB_NAMESPACE::port::Thread threads1([&] { ROCKSDB_NAMESPACE::port::Thread threads1([&] {
@ -1811,7 +1812,7 @@ TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactions) {
PutRandomData(1, 10, 12000, true); PutRandomData(1, 10, 12000, true);
PutRandomData(1, 1, 10, true); PutRandomData(1, 1, 10, true);
WaitForFlush(1); WaitForFlush(1);
AssertFilesPerLevel(ToString(i + 1), 1); AssertFilesPerLevel(std::to_string(i + 1), 1);
} }
bool cf_1_1 = true; bool cf_1_1 = true;
bool cf_1_2 = true; bool cf_1_2 = true;
@ -1849,8 +1850,8 @@ TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactions) {
PutRandomData(1, 10, 12000, true); PutRandomData(1, 10, 12000, true);
PutRandomData(1, 1, 10, true); PutRandomData(1, 1, 10, true);
WaitForFlush(1); WaitForFlush(1);
AssertFilesPerLevel(ToString(one.level0_file_num_compaction_trigger + i), AssertFilesPerLevel(
1); std::to_string(one.level0_file_num_compaction_trigger + i), 1);
} }
TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:1"); TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:1");
@ -1904,7 +1905,7 @@ TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactionsLevel) {
PutRandomData(1, 10, 12000, true); PutRandomData(1, 10, 12000, true);
PutRandomData(1, 1, 10, true); PutRandomData(1, 1, 10, true);
WaitForFlush(1); WaitForFlush(1);
AssertFilesPerLevel(ToString(i + 1), 1); AssertFilesPerLevel(std::to_string(i + 1), 1);
} }
bool cf_1_1 = true; bool cf_1_1 = true;
bool cf_1_2 = true; bool cf_1_2 = true;
@ -1942,8 +1943,8 @@ TEST_P(ColumnFamilyTest, SameCFManualAutomaticCompactionsLevel) {
PutRandomData(1, 10, 12000, true); PutRandomData(1, 10, 12000, true);
PutRandomData(1, 1, 10, true); PutRandomData(1, 1, 10, true);
WaitForFlush(1); WaitForFlush(1);
AssertFilesPerLevel(ToString(one.level0_file_num_compaction_trigger + i), AssertFilesPerLevel(
1); std::to_string(one.level0_file_num_compaction_trigger + i), 1);
} }
TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:1"); TEST_SYNC_POINT("ColumnFamilyTest::ManualAuto:1");
@ -2024,7 +2025,7 @@ TEST_P(ColumnFamilyTest, SameCFAutomaticManualCompactions) {
PutRandomData(1, 10, 12000, true); PutRandomData(1, 10, 12000, true);
PutRandomData(1, 1, 10, true); PutRandomData(1, 1, 10, true);
WaitForFlush(1); WaitForFlush(1);
AssertFilesPerLevel(ToString(i + 1), 1); AssertFilesPerLevel(std::to_string(i + 1), 1);
} }
TEST_SYNC_POINT("ColumnFamilyTest::AutoManual:5"); TEST_SYNC_POINT("ColumnFamilyTest::AutoManual:5");

View File

@ -91,8 +91,8 @@ TEST_F(CompactFilesTest, L0ConflictsFiles) {
// create couple files // create couple files
// Background compaction starts and waits in BackgroundCallCompaction:0 // Background compaction starts and waits in BackgroundCallCompaction:0
for (int i = 0; i < kLevel0Trigger * 4; ++i) { for (int i = 0; i < kLevel0Trigger * 4; ++i) {
ASSERT_OK(db->Put(WriteOptions(), ToString(i), "")); ASSERT_OK(db->Put(WriteOptions(), std::to_string(i), ""));
ASSERT_OK(db->Put(WriteOptions(), ToString(100 - i), "")); ASSERT_OK(db->Put(WriteOptions(), std::to_string(100 - i), ""));
ASSERT_OK(db->Flush(FlushOptions())); ASSERT_OK(db->Flush(FlushOptions()));
} }
@ -136,7 +136,7 @@ TEST_F(CompactFilesTest, MultipleLevel) {
// create couple files in L0, L3, L4 and L5 // create couple files in L0, L3, L4 and L5
for (int i = 5; i > 2; --i) { for (int i = 5; i > 2; --i) {
collector->ClearFlushedFiles(); collector->ClearFlushedFiles();
ASSERT_OK(db->Put(WriteOptions(), ToString(i), "")); ASSERT_OK(db->Put(WriteOptions(), std::to_string(i), ""));
ASSERT_OK(db->Flush(FlushOptions())); ASSERT_OK(db->Flush(FlushOptions()));
// Ensure background work is fully finished including listener callbacks // Ensure background work is fully finished including listener callbacks
// before accessing listener state. // before accessing listener state.
@ -145,11 +145,11 @@ TEST_F(CompactFilesTest, MultipleLevel) {
ASSERT_OK(db->CompactFiles(CompactionOptions(), l0_files, i)); ASSERT_OK(db->CompactFiles(CompactionOptions(), l0_files, i));
std::string prop; std::string prop;
ASSERT_TRUE( ASSERT_TRUE(db->GetProperty(
db->GetProperty("rocksdb.num-files-at-level" + ToString(i), &prop)); "rocksdb.num-files-at-level" + std::to_string(i), &prop));
ASSERT_EQ("1", prop); ASSERT_EQ("1", prop);
} }
ASSERT_OK(db->Put(WriteOptions(), ToString(0), "")); ASSERT_OK(db->Put(WriteOptions(), std::to_string(0), ""));
ASSERT_OK(db->Flush(FlushOptions())); ASSERT_OK(db->Flush(FlushOptions()));
ColumnFamilyMetaData meta; ColumnFamilyMetaData meta;
@ -218,7 +218,7 @@ TEST_F(CompactFilesTest, ObsoleteFiles) {
// create couple files // create couple files
for (int i = 1000; i < 2000; ++i) { for (int i = 1000; i < 2000; ++i) {
ASSERT_OK(db->Put(WriteOptions(), ToString(i), ASSERT_OK(db->Put(WriteOptions(), std::to_string(i),
std::string(kWriteBufferSize / 10, 'a' + (i % 26)))); std::string(kWriteBufferSize / 10, 'a' + (i % 26))));
} }
@ -257,14 +257,14 @@ TEST_F(CompactFilesTest, NotCutOutputOnLevel0) {
// create couple files // create couple files
for (int i = 0; i < 500; ++i) { for (int i = 0; i < 500; ++i) {
ASSERT_OK(db->Put(WriteOptions(), ToString(i), ASSERT_OK(db->Put(WriteOptions(), std::to_string(i),
std::string(1000, 'a' + (i % 26)))); std::string(1000, 'a' + (i % 26))));
} }
ASSERT_OK(static_cast_with_check<DBImpl>(db)->TEST_WaitForFlushMemTable()); ASSERT_OK(static_cast_with_check<DBImpl>(db)->TEST_WaitForFlushMemTable());
auto l0_files_1 = collector->GetFlushedFiles(); auto l0_files_1 = collector->GetFlushedFiles();
collector->ClearFlushedFiles(); collector->ClearFlushedFiles();
for (int i = 0; i < 500; ++i) { for (int i = 0; i < 500; ++i) {
ASSERT_OK(db->Put(WriteOptions(), ToString(i), ASSERT_OK(db->Put(WriteOptions(), std::to_string(i),
std::string(1000, 'a' + (i % 26)))); std::string(1000, 'a' + (i % 26))));
} }
ASSERT_OK(static_cast_with_check<DBImpl>(db)->TEST_WaitForFlushMemTable()); ASSERT_OK(static_cast_with_check<DBImpl>(db)->TEST_WaitForFlushMemTable());
@ -295,7 +295,7 @@ TEST_F(CompactFilesTest, CapturingPendingFiles) {
// Create 5 files. // Create 5 files.
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {
ASSERT_OK(db->Put(WriteOptions(), "key" + ToString(i), "value")); ASSERT_OK(db->Put(WriteOptions(), "key" + std::to_string(i), "value"));
ASSERT_OK(db->Flush(FlushOptions())); ASSERT_OK(db->Flush(FlushOptions()));
} }
@ -465,7 +465,7 @@ TEST_F(CompactFilesTest, GetCompactionJobInfo) {
// create couple files // create couple files
for (int i = 0; i < 500; ++i) { for (int i = 0; i < 500; ++i) {
ASSERT_OK(db->Put(WriteOptions(), ToString(i), ASSERT_OK(db->Put(WriteOptions(), std::to_string(i),
std::string(1000, 'a' + (i % 26)))); std::string(1000, 'a' + (i % 26))));
} }
ASSERT_OK(static_cast_with_check<DBImpl>(db)->TEST_WaitForFlushMemTable()); ASSERT_OK(static_cast_with_check<DBImpl>(db)->TEST_WaitForFlushMemTable());

View File

@ -313,7 +313,7 @@ class CompactionIteratorTest : public testing::TestWithParam<bool> {
key_not_exists_beyond_output_level, full_history_ts_low); key_not_exists_beyond_output_level, full_history_ts_low);
c_iter_->SeekToFirst(); c_iter_->SeekToFirst();
for (size_t i = 0; i < expected_keys.size(); i++) { for (size_t i = 0; i < expected_keys.size(); i++) {
std::string info = "i = " + ToString(i); std::string info = "i = " + std::to_string(i);
ASSERT_TRUE(c_iter_->Valid()) << info; ASSERT_TRUE(c_iter_->Valid()) << info;
ASSERT_OK(c_iter_->status()) << info; ASSERT_OK(c_iter_->status()) << info;
ASSERT_EQ(expected_keys[i], c_iter_->key().ToString()) << info; ASSERT_EQ(expected_keys[i], c_iter_->key().ToString()) << info;

View File

@ -2459,7 +2459,7 @@ void CompactionJob::LogCompaction() {
<< "compaction_reason" << "compaction_reason"
<< GetCompactionReasonString(compaction->compaction_reason()); << GetCompactionReasonString(compaction->compaction_reason());
for (size_t i = 0; i < compaction->num_input_levels(); ++i) { for (size_t i = 0; i < compaction->num_input_levels(); ++i) {
stream << ("files_L" + ToString(compaction->level(i))); stream << ("files_L" + std::to_string(compaction->level(i)));
stream.StartArray(); stream.StartArray();
for (auto f : *compaction->inputs(i)) { for (auto f : *compaction->inputs(i)) {
stream << f->fd.GetNumber(); stream << f->fd.GetNumber();
@ -3009,7 +3009,7 @@ Status CompactionServiceInput::Read(const std::string& data_str,
} else { } else {
return Status::NotSupported( return Status::NotSupported(
"Compaction Service Input data version not supported: " + "Compaction Service Input data version not supported: " +
ToString(format_version)); std::to_string(format_version));
} }
} }
@ -3038,7 +3038,7 @@ Status CompactionServiceResult::Read(const std::string& data_str,
} else { } else {
return Status::NotSupported( return Status::NotSupported(
"Compaction Service Result data version not supported: " + "Compaction Service Result data version not supported: " +
ToString(format_version)); std::to_string(format_version));
} }
} }

View File

@ -268,10 +268,10 @@ class CompactionJobStatsTest : public testing::Test,
if (cf == 0) { if (cf == 0) {
// default cfd // default cfd
EXPECT_TRUE(db_->GetProperty( EXPECT_TRUE(db_->GetProperty(
"rocksdb.num-files-at-level" + ToString(level), &property)); "rocksdb.num-files-at-level" + std::to_string(level), &property));
} else { } else {
EXPECT_TRUE(db_->GetProperty( EXPECT_TRUE(db_->GetProperty(
handles_[cf], "rocksdb.num-files-at-level" + ToString(level), handles_[cf], "rocksdb.num-files-at-level" + std::to_string(level),
&property)); &property));
} }
return atoi(property.c_str()); return atoi(property.c_str());
@ -672,7 +672,7 @@ TEST_P(CompactionJobStatsTest, CompactionJobStatsTest) {
snprintf(buf, kBufSize, "%d", ++num_L0_files); snprintf(buf, kBufSize, "%d", ++num_L0_files);
ASSERT_EQ(std::string(buf), FilesPerLevel(1)); ASSERT_EQ(std::string(buf), FilesPerLevel(1));
} }
ASSERT_EQ(ToString(num_L0_files), FilesPerLevel(1)); ASSERT_EQ(std::to_string(num_L0_files), FilesPerLevel(1));
// 2nd Phase: perform L0 -> L1 compaction. // 2nd Phase: perform L0 -> L1 compaction.
int L0_compaction_count = 6; int L0_compaction_count = 6;

View File

@ -236,8 +236,8 @@ class CompactionJobTestBase : public testing::Test {
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
auto contents = mock::MakeMockFile(); auto contents = mock::MakeMockFile();
for (int k = 0; k < kKeysPerFile; ++k) { for (int k = 0; k < kKeysPerFile; ++k) {
auto key = ToString(i * kMatchingKeys + k); auto key = std::to_string(i * kMatchingKeys + k);
auto value = ToString(i * kKeysPerFile + k); auto value = std::to_string(i * kKeysPerFile + k);
InternalKey internal_key(key, ++sequence_number, kTypeValue); InternalKey internal_key(key, ++sequence_number, kTypeValue);
// This is how the key will look like once it's written in bottommost // This is how the key will look like once it's written in bottommost

View File

@ -401,7 +401,7 @@ Status CompactionPicker::GetCompactionInputsFromFileNumbers(
"Cannot find matched SST files for the following file numbers:"); "Cannot find matched SST files for the following file numbers:");
for (auto fn : *input_set) { for (auto fn : *input_set) {
message += " "; message += " ";
message += ToString(fn); message += std::to_string(fn);
} }
return Status::InvalidArgument(message); return Status::InvalidArgument(message);
} }
@ -1004,14 +1004,14 @@ Status CompactionPicker::SanitizeCompactionInputFiles(
return Status::InvalidArgument( return Status::InvalidArgument(
"Output level for column family " + cf_meta.name + "Output level for column family " + cf_meta.name +
" must between [0, " + " must between [0, " +
ToString(cf_meta.levels[cf_meta.levels.size() - 1].level) + "]."); std::to_string(cf_meta.levels[cf_meta.levels.size() - 1].level) + "].");
} }
if (output_level > MaxOutputLevel()) { if (output_level > MaxOutputLevel()) {
return Status::InvalidArgument( return Status::InvalidArgument(
"Exceed the maximum output level defined by " "Exceed the maximum output level defined by "
"the current compaction algorithm --- " + "the current compaction algorithm --- " +
ToString(MaxOutputLevel())); std::to_string(MaxOutputLevel()));
} }
if (output_level < 0) { if (output_level < 0) {
@ -1061,8 +1061,8 @@ Status CompactionPicker::SanitizeCompactionInputFiles(
return Status::InvalidArgument( return Status::InvalidArgument(
"Cannot compact file to up level, input file: " + "Cannot compact file to up level, input file: " +
MakeTableFileName("", file_num) + " level " + MakeTableFileName("", file_num) + " level " +
ToString(input_file_level) + " > output level " + std::to_string(input_file_level) + " > output level " +
ToString(output_level)); std::to_string(output_level));
} }
} }

View File

@ -273,9 +273,9 @@ TEST_F(CompactionPickerTest, NeedsCompactionLevel) {
// start a brand new version in each test. // start a brand new version in each test.
NewVersionStorage(kLevels, kCompactionStyleLevel); NewVersionStorage(kLevels, kCompactionStyleLevel);
for (int i = 0; i < file_count; ++i) { for (int i = 0; i < file_count; ++i) {
Add(level, i, ToString((i + 100) * 1000).c_str(), Add(level, i, std::to_string((i + 100) * 1000).c_str(),
ToString((i + 100) * 1000 + 999).c_str(), std::to_string((i + 100) * 1000 + 999).c_str(), file_size, 0,
file_size, 0, i * 100, i * 100 + 99); i * 100, i * 100 + 99);
} }
UpdateVersionStorageInfo(); UpdateVersionStorageInfo();
ASSERT_EQ(vstorage_->CompactionScoreLevel(0), level); ASSERT_EQ(vstorage_->CompactionScoreLevel(0), level);
@ -439,8 +439,8 @@ TEST_F(CompactionPickerTest, NeedsCompactionUniversal) {
for (int i = 1; for (int i = 1;
i <= mutable_cf_options_.level0_file_num_compaction_trigger * 2; ++i) { i <= mutable_cf_options_.level0_file_num_compaction_trigger * 2; ++i) {
NewVersionStorage(1, kCompactionStyleUniversal); NewVersionStorage(1, kCompactionStyleUniversal);
Add(0, i, ToString((i + 100) * 1000).c_str(), Add(0, i, std::to_string((i + 100) * 1000).c_str(),
ToString((i + 100) * 1000 + 999).c_str(), 1000000, 0, i * 100, std::to_string((i + 100) * 1000 + 999).c_str(), 1000000, 0, i * 100,
i * 100 + 99); i * 100 + 99);
UpdateVersionStorageInfo(); UpdateVersionStorageInfo();
ASSERT_EQ(level_compaction_picker.NeedsCompaction(vstorage_.get()), ASSERT_EQ(level_compaction_picker.NeedsCompaction(vstorage_.get()),
@ -852,17 +852,17 @@ TEST_F(CompactionPickerTest, UniversalIncrementalSpace4) {
// L3: (1101, 1180) (1201, 1280) ... (7901, 7908) // L3: (1101, 1180) (1201, 1280) ... (7901, 7908)
// L4: (1130, 1150) (1160, 1210) (1230, 1250) (1260 1310) ... (7960, 8010) // L4: (1130, 1150) (1160, 1210) (1230, 1250) (1260 1310) ... (7960, 8010)
for (int i = 11; i < 79; i++) { for (int i = 11; i < 79; i++) {
Add(3, 100 + i * 3, ToString(i * 100).c_str(), Add(3, 100 + i * 3, std::to_string(i * 100).c_str(),
ToString(i * 100 + 80).c_str(), kFileSize, 0, 200, 251); std::to_string(i * 100 + 80).c_str(), kFileSize, 0, 200, 251);
// Add a tie breaker // Add a tie breaker
if (i == 66) { if (i == 66) {
Add(3, 10000U, "6690", "6699", kFileSize, 0, 200, 251); Add(3, 10000U, "6690", "6699", kFileSize, 0, 200, 251);
} }
Add(4, 100 + i * 3 + 1, ToString(i * 100 + 30).c_str(), Add(4, 100 + i * 3 + 1, std::to_string(i * 100 + 30).c_str(),
ToString(i * 100 + 50).c_str(), kFileSize, 0, 200, 251); std::to_string(i * 100 + 50).c_str(), kFileSize, 0, 200, 251);
Add(4, 100 + i * 3 + 2, ToString(i * 100 + 60).c_str(), Add(4, 100 + i * 3 + 2, std::to_string(i * 100 + 60).c_str(),
ToString(i * 100 + 110).c_str(), kFileSize, 0, 200, 251); std::to_string(i * 100 + 110).c_str(), kFileSize, 0, 200, 251);
} }
UpdateVersionStorageInfo(); UpdateVersionStorageInfo();
@ -899,14 +899,14 @@ TEST_F(CompactionPickerTest, UniversalIncrementalSpace5) {
// L3: (1101, 1180) (1201, 1280) ... (7901, 7908) // L3: (1101, 1180) (1201, 1280) ... (7901, 7908)
// L4: (1130, 1150) (1160, 1210) (1230, 1250) (1260 1310) ... (7960, 8010) // L4: (1130, 1150) (1160, 1210) (1230, 1250) (1260 1310) ... (7960, 8010)
for (int i = 11; i < 70; i++) { for (int i = 11; i < 70; i++) {
Add(3, 100 + i * 3, ToString(i * 100).c_str(), Add(3, 100 + i * 3, std::to_string(i * 100).c_str(),
ToString(i * 100 + 80).c_str(), std::to_string(i * 100 + 80).c_str(),
i % 10 == 9 ? kFileSize * 100 : kFileSize, 0, 200, 251); i % 10 == 9 ? kFileSize * 100 : kFileSize, 0, 200, 251);
Add(4, 100 + i * 3 + 1, ToString(i * 100 + 30).c_str(), Add(4, 100 + i * 3 + 1, std::to_string(i * 100 + 30).c_str(),
ToString(i * 100 + 50).c_str(), kFileSize, 0, 200, 251); std::to_string(i * 100 + 50).c_str(), kFileSize, 0, 200, 251);
Add(4, 100 + i * 3 + 2, ToString(i * 100 + 60).c_str(), Add(4, 100 + i * 3 + 2, std::to_string(i * 100 + 60).c_str(),
ToString(i * 100 + 110).c_str(), kFileSize, 0, 200, 251); std::to_string(i * 100 + 110).c_str(), kFileSize, 0, 200, 251);
} }
UpdateVersionStorageInfo(); UpdateVersionStorageInfo();
@ -941,8 +941,8 @@ TEST_F(CompactionPickerTest, NeedsCompactionFIFO) {
// size of L0 files. // size of L0 files.
for (int i = 1; i <= kFileCount; ++i) { for (int i = 1; i <= kFileCount; ++i) {
NewVersionStorage(1, kCompactionStyleFIFO); NewVersionStorage(1, kCompactionStyleFIFO);
Add(0, i, ToString((i + 100) * 1000).c_str(), Add(0, i, std::to_string((i + 100) * 1000).c_str(),
ToString((i + 100) * 1000 + 999).c_str(), kFileSize, 0, i * 100, std::to_string((i + 100) * 1000 + 999).c_str(), kFileSize, 0, i * 100,
i * 100 + 99); i * 100 + 99);
UpdateVersionStorageInfo(); UpdateVersionStorageInfo();
ASSERT_EQ(fifo_compaction_picker.NeedsCompaction(vstorage_.get()), ASSERT_EQ(fifo_compaction_picker.NeedsCompaction(vstorage_.get()),

View File

@ -82,8 +82,7 @@ class MyTestCompactionService : public CompactionService {
options.canceled = &canceled_; options.canceled = &canceled_;
Status s = DB::OpenAndCompact( Status s = DB::OpenAndCompact(
options, db_path_, options, db_path_, db_path_ + "/" + std::to_string(info.job_id),
db_path_ + "/" + ROCKSDB_NAMESPACE::ToString(info.job_id),
compaction_input, compaction_service_result, options_override); compaction_input, compaction_service_result, options_override);
if (is_override_wait_result_) { if (is_override_wait_result_) {
*compaction_service_result = override_wait_result_; *compaction_service_result = override_wait_result_;
@ -177,7 +176,7 @@ class CompactionServiceTest : public DBTestBase {
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 10 + j; int key_id = i * 10 + j;
ASSERT_OK(Put(Key(key_id), "value" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -187,7 +186,7 @@ class CompactionServiceTest : public DBTestBase {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 20 + j * 2; int key_id = i * 20 + j * 2;
ASSERT_OK(Put(Key(key_id), "value_new" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value_new" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -199,9 +198,9 @@ class CompactionServiceTest : public DBTestBase {
for (int i = 0; i < 200; i++) { for (int i = 0; i < 200; i++) {
auto result = Get(Key(i)); auto result = Get(Key(i));
if (i % 2) { if (i % 2) {
ASSERT_EQ(result, "value" + ToString(i)); ASSERT_EQ(result, "value" + std::to_string(i));
} else { } else {
ASSERT_EQ(result, "value_new" + ToString(i)); ASSERT_EQ(result, "value_new" + std::to_string(i));
} }
} }
} }
@ -224,7 +223,7 @@ TEST_F(CompactionServiceTest, BasicCompactions) {
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 10 + j; int key_id = i * 10 + j;
ASSERT_OK(Put(Key(key_id), "value" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -232,7 +231,7 @@ TEST_F(CompactionServiceTest, BasicCompactions) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 20 + j * 2; int key_id = i * 20 + j * 2;
ASSERT_OK(Put(Key(key_id), "value_new" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value_new" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -242,9 +241,9 @@ TEST_F(CompactionServiceTest, BasicCompactions) {
for (int i = 0; i < 200; i++) { for (int i = 0; i < 200; i++) {
auto result = Get(Key(i)); auto result = Get(Key(i));
if (i % 2) { if (i % 2) {
ASSERT_EQ(result, "value" + ToString(i)); ASSERT_EQ(result, "value" + std::to_string(i));
} else { } else {
ASSERT_EQ(result, "value_new" + ToString(i)); ASSERT_EQ(result, "value_new" + std::to_string(i));
} }
} }
auto my_cs = GetCompactionService(); auto my_cs = GetCompactionService();
@ -281,7 +280,7 @@ TEST_F(CompactionServiceTest, BasicCompactions) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 20 + j * 2; int key_id = i * 20 + j * 2;
s = Put(Key(key_id), "value_new" + ToString(key_id)); s = Put(Key(key_id), "value_new" + std::to_string(key_id));
if (s.IsAborted()) { if (s.IsAborted()) {
break; break;
} }
@ -468,7 +467,7 @@ TEST_F(CompactionServiceTest, CompactionFilter) {
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 10 + j; int key_id = i * 10 + j;
ASSERT_OK(Put(Key(key_id), "value" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -476,7 +475,7 @@ TEST_F(CompactionServiceTest, CompactionFilter) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 20 + j * 2; int key_id = i * 20 + j * 2;
ASSERT_OK(Put(Key(key_id), "value_new" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value_new" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -490,9 +489,9 @@ TEST_F(CompactionServiceTest, CompactionFilter) {
if (i > 5 && i <= 105) { if (i > 5 && i <= 105) {
ASSERT_EQ(result, "NOT_FOUND"); ASSERT_EQ(result, "NOT_FOUND");
} else if (i % 2) { } else if (i % 2) {
ASSERT_EQ(result, "value" + ToString(i)); ASSERT_EQ(result, "value" + std::to_string(i));
} else { } else {
ASSERT_EQ(result, "value_new" + ToString(i)); ASSERT_EQ(result, "value_new" + std::to_string(i));
} }
} }
auto my_cs = GetCompactionService(); auto my_cs = GetCompactionService();
@ -547,9 +546,9 @@ TEST_F(CompactionServiceTest, ConcurrentCompaction) {
for (int i = 0; i < 200; i++) { for (int i = 0; i < 200; i++) {
auto result = Get(Key(i)); auto result = Get(Key(i));
if (i % 2) { if (i % 2) {
ASSERT_EQ(result, "value" + ToString(i)); ASSERT_EQ(result, "value" + std::to_string(i));
} else { } else {
ASSERT_EQ(result, "value_new" + ToString(i)); ASSERT_EQ(result, "value_new" + std::to_string(i));
} }
} }
auto my_cs = GetCompactionService(); auto my_cs = GetCompactionService();
@ -564,7 +563,7 @@ TEST_F(CompactionServiceTest, CompactionInfo) {
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 10 + j; int key_id = i * 10 + j;
ASSERT_OK(Put(Key(key_id), "value" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -572,7 +571,7 @@ TEST_F(CompactionServiceTest, CompactionInfo) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 20 + j * 2; int key_id = i * 20 + j * 2;
ASSERT_OK(Put(Key(key_id), "value_new" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value_new" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -617,7 +616,7 @@ TEST_F(CompactionServiceTest, CompactionInfo) {
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 10 + j; int key_id = i * 10 + j;
ASSERT_OK(Put(Key(key_id), "value" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -625,7 +624,7 @@ TEST_F(CompactionServiceTest, CompactionInfo) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 20 + j * 2; int key_id = i * 20 + j * 2;
ASSERT_OK(Put(Key(key_id), "value_new" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value_new" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -653,7 +652,7 @@ TEST_F(CompactionServiceTest, FallbackLocalAuto) {
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 10 + j; int key_id = i * 10 + j;
ASSERT_OK(Put(Key(key_id), "value" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -661,7 +660,7 @@ TEST_F(CompactionServiceTest, FallbackLocalAuto) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 20 + j * 2; int key_id = i * 20 + j * 2;
ASSERT_OK(Put(Key(key_id), "value_new" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value_new" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -671,9 +670,9 @@ TEST_F(CompactionServiceTest, FallbackLocalAuto) {
for (int i = 0; i < 200; i++) { for (int i = 0; i < 200; i++) {
auto result = Get(Key(i)); auto result = Get(Key(i));
if (i % 2) { if (i % 2) {
ASSERT_EQ(result, "value" + ToString(i)); ASSERT_EQ(result, "value" + std::to_string(i));
} else { } else {
ASSERT_EQ(result, "value_new" + ToString(i)); ASSERT_EQ(result, "value_new" + std::to_string(i));
} }
} }
@ -796,7 +795,7 @@ TEST_F(CompactionServiceTest, RemoteEventListener) {
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 10 + j; int key_id = i * 10 + j;
ASSERT_OK(Put(Key(key_id), "value" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -804,7 +803,7 @@ TEST_F(CompactionServiceTest, RemoteEventListener) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 20 + j * 2; int key_id = i * 20 + j * 2;
ASSERT_OK(Put(Key(key_id), "value_new" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value_new" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -821,9 +820,9 @@ TEST_F(CompactionServiceTest, RemoteEventListener) {
for (int i = 0; i < 200; i++) { for (int i = 0; i < 200; i++) {
auto result = Get(Key(i)); auto result = Get(Key(i));
if (i % 2) { if (i % 2) {
ASSERT_EQ(result, "value" + ToString(i)); ASSERT_EQ(result, "value" + std::to_string(i));
} else { } else {
ASSERT_EQ(result, "value_new" + ToString(i)); ASSERT_EQ(result, "value_new" + std::to_string(i));
} }
} }
} }

View File

@ -397,7 +397,7 @@ TEST_P(ComparatorDBTest, DoubleComparator) {
for (uint32_t j = 0; j < divide_order; j++) { for (uint32_t j = 0; j < divide_order; j++) {
to_divide *= 10.0; to_divide *= 10.0;
} }
source_strings.push_back(ToString(r / to_divide)); source_strings.push_back(std::to_string(r / to_divide));
} }
DoRandomIteraratorTest(GetDB(), source_strings, &rnd, 200, 1000, 66); DoRandomIteraratorTest(GetDB(), source_strings, &rnd, 200, 1000, 66);

View File

@ -95,8 +95,8 @@ class CuckooTableDBTest : public testing::Test {
int NumTableFilesAtLevel(int level) { int NumTableFilesAtLevel(int level) {
std::string property; std::string property;
EXPECT_TRUE(db_->GetProperty("rocksdb.num-files-at-level" + ToString(level), EXPECT_TRUE(db_->GetProperty(
&property)); "rocksdb.num-files-at-level" + std::to_string(level), &property));
return atoi(property.c_str()); return atoi(property.c_str());
} }

View File

@ -3783,7 +3783,7 @@ TEST_P(DBBasicTestDeadline, PointLookupDeadline) {
Random rnd(301); Random rnd(301);
for (int i = 0; i < 400; ++i) { for (int i = 0; i < 400; ++i) {
std::string key = "k" + ToString(i); std::string key = "k" + std::to_string(i);
ASSERT_OK(Put(key, rnd.RandomString(100))); ASSERT_OK(Put(key, rnd.RandomString(100)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
@ -3866,7 +3866,7 @@ TEST_P(DBBasicTestDeadline, IteratorDeadline) {
Random rnd(301); Random rnd(301);
for (int i = 0; i < 400; ++i) { for (int i = 0; i < 400; ++i) {
std::string key = "k" + ToString(i); std::string key = "k" + std::to_string(i);
ASSERT_OK(Put(key, rnd.RandomString(100))); ASSERT_OK(Put(key, rnd.RandomString(100)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());

View File

@ -76,7 +76,7 @@ class DBBlockCacheTest : public DBTestBase {
void InitTable(const Options& /*options*/) { void InitTable(const Options& /*options*/) {
std::string value(kValueSize, 'a'); std::string value(kValueSize, 'a');
for (size_t i = 0; i < kNumBlocks; i++) { for (size_t i = 0; i < kNumBlocks; i++) {
ASSERT_OK(Put(ToString(i), value.c_str())); ASSERT_OK(Put(std::to_string(i), value.c_str()));
} }
} }
@ -205,7 +205,7 @@ TEST_F(DBBlockCacheTest, IteratorBlockCacheUsage) {
ASSERT_EQ(0, cache->GetUsage()); ASSERT_EQ(0, cache->GetUsage());
iter = db_->NewIterator(read_options); iter = db_->NewIterator(read_options);
iter->Seek(ToString(0)); iter->Seek(std::to_string(0));
ASSERT_LT(0, cache->GetUsage()); ASSERT_LT(0, cache->GetUsage());
delete iter; delete iter;
iter = nullptr; iter = nullptr;
@ -236,7 +236,7 @@ TEST_F(DBBlockCacheTest, TestWithoutCompressedBlockCache) {
// Load blocks into cache. // Load blocks into cache.
for (size_t i = 0; i + 1 < kNumBlocks; i++) { for (size_t i = 0; i + 1 < kNumBlocks; i++) {
iter = db_->NewIterator(read_options); iter = db_->NewIterator(read_options);
iter->Seek(ToString(i)); iter->Seek(std::to_string(i));
ASSERT_OK(iter->status()); ASSERT_OK(iter->status());
CheckCacheCounters(options, 1, 0, 1, 0); CheckCacheCounters(options, 1, 0, 1, 0);
iterators[i].reset(iter); iterators[i].reset(iter);
@ -249,7 +249,7 @@ TEST_F(DBBlockCacheTest, TestWithoutCompressedBlockCache) {
// Test with strict capacity limit. // Test with strict capacity limit.
cache->SetStrictCapacityLimit(true); cache->SetStrictCapacityLimit(true);
iter = db_->NewIterator(read_options); iter = db_->NewIterator(read_options);
iter->Seek(ToString(kNumBlocks - 1)); iter->Seek(std::to_string(kNumBlocks - 1));
ASSERT_TRUE(iter->status().IsIncomplete()); ASSERT_TRUE(iter->status().IsIncomplete());
CheckCacheCounters(options, 1, 0, 0, 1); CheckCacheCounters(options, 1, 0, 0, 1);
delete iter; delete iter;
@ -263,7 +263,7 @@ TEST_F(DBBlockCacheTest, TestWithoutCompressedBlockCache) {
ASSERT_EQ(0, cache->GetPinnedUsage()); ASSERT_EQ(0, cache->GetPinnedUsage());
for (size_t i = 0; i + 1 < kNumBlocks; i++) { for (size_t i = 0; i + 1 < kNumBlocks; i++) {
iter = db_->NewIterator(read_options); iter = db_->NewIterator(read_options);
iter->Seek(ToString(i)); iter->Seek(std::to_string(i));
ASSERT_OK(iter->status()); ASSERT_OK(iter->status());
CheckCacheCounters(options, 0, 1, 0, 0); CheckCacheCounters(options, 0, 1, 0, 0);
iterators[i].reset(iter); iterators[i].reset(iter);
@ -289,7 +289,7 @@ TEST_F(DBBlockCacheTest, TestWithCompressedBlockCache) {
std::string value(kValueSize, 'a'); std::string value(kValueSize, 'a');
for (size_t i = 0; i < kNumBlocks; i++) { for (size_t i = 0; i < kNumBlocks; i++) {
ASSERT_OK(Put(ToString(i), value)); ASSERT_OK(Put(std::to_string(i), value));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -313,7 +313,7 @@ TEST_F(DBBlockCacheTest, TestWithCompressedBlockCache) {
// Load blocks into cache. // Load blocks into cache.
for (size_t i = 0; i < kNumBlocks - 1; i++) { for (size_t i = 0; i < kNumBlocks - 1; i++) {
ASSERT_EQ(value, Get(ToString(i))); ASSERT_EQ(value, Get(std::to_string(i)));
CheckCacheCounters(options, 1, 0, 1, 0); CheckCacheCounters(options, 1, 0, 1, 0);
CheckCompressedCacheCounters(options, 1, 0, 1, 0); CheckCompressedCacheCounters(options, 1, 0, 1, 0);
} }
@ -334,7 +334,7 @@ TEST_F(DBBlockCacheTest, TestWithCompressedBlockCache) {
// Load last key block. // Load last key block.
ASSERT_EQ("Result incomplete: Insert failed due to LRU cache being full.", ASSERT_EQ("Result incomplete: Insert failed due to LRU cache being full.",
Get(ToString(kNumBlocks - 1))); Get(std::to_string(kNumBlocks - 1)));
// Failure will also record the miss counter. // Failure will also record the miss counter.
CheckCacheCounters(options, 1, 0, 0, 1); CheckCacheCounters(options, 1, 0, 0, 1);
CheckCompressedCacheCounters(options, 1, 0, 1, 0); CheckCompressedCacheCounters(options, 1, 0, 1, 0);
@ -343,7 +343,7 @@ TEST_F(DBBlockCacheTest, TestWithCompressedBlockCache) {
// cache and load into block cache. // cache and load into block cache.
cache->SetStrictCapacityLimit(false); cache->SetStrictCapacityLimit(false);
// Load last key block. // Load last key block.
ASSERT_EQ(value, Get(ToString(kNumBlocks - 1))); ASSERT_EQ(value, Get(std::to_string(kNumBlocks - 1)));
CheckCacheCounters(options, 1, 0, 1, 0); CheckCacheCounters(options, 1, 0, 1, 0);
CheckCompressedCacheCounters(options, 0, 1, 0, 0); CheckCompressedCacheCounters(options, 0, 1, 0, 0);
} }
@ -568,7 +568,7 @@ TEST_F(DBBlockCacheTest, FillCacheAndIterateDB) {
Iterator* iter = nullptr; Iterator* iter = nullptr;
iter = db_->NewIterator(read_options); iter = db_->NewIterator(read_options);
iter->Seek(ToString(0)); iter->Seek(std::to_string(0));
while (iter->Valid()) { while (iter->Valid()) {
iter->Next(); iter->Next();
} }
@ -646,10 +646,10 @@ TEST_F(DBBlockCacheTest, WarmCacheWithDataBlocksDuringFlush) {
std::string value(kValueSize, 'a'); std::string value(kValueSize, 'a');
for (size_t i = 1; i <= kNumBlocks; i++) { for (size_t i = 1; i <= kNumBlocks; i++) {
ASSERT_OK(Put(ToString(i), value)); ASSERT_OK(Put(std::to_string(i), value));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_EQ(i, options.statistics->getTickerCount(BLOCK_CACHE_DATA_ADD)); ASSERT_EQ(i, options.statistics->getTickerCount(BLOCK_CACHE_DATA_ADD));
ASSERT_EQ(value, Get(ToString(i))); ASSERT_EQ(value, Get(std::to_string(i)));
ASSERT_EQ(0, options.statistics->getTickerCount(BLOCK_CACHE_DATA_MISS)); ASSERT_EQ(0, options.statistics->getTickerCount(BLOCK_CACHE_DATA_MISS));
ASSERT_EQ(i, options.statistics->getTickerCount(BLOCK_CACHE_DATA_HIT)); ASSERT_EQ(i, options.statistics->getTickerCount(BLOCK_CACHE_DATA_HIT));
} }
@ -706,7 +706,7 @@ TEST_P(DBBlockCacheTest1, WarmCacheWithBlocksDuringFlush) {
std::string value(kValueSize, 'a'); std::string value(kValueSize, 'a');
for (size_t i = 1; i <= kNumBlocks; i++) { for (size_t i = 1; i <= kNumBlocks; i++) {
ASSERT_OK(Put(ToString(i), value)); ASSERT_OK(Put(std::to_string(i), value));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_EQ(i, options.statistics->getTickerCount(BLOCK_CACHE_DATA_ADD)); ASSERT_EQ(i, options.statistics->getTickerCount(BLOCK_CACHE_DATA_ADD));
if (filter_type == 1) { if (filter_type == 1) {
@ -718,7 +718,7 @@ TEST_P(DBBlockCacheTest1, WarmCacheWithBlocksDuringFlush) {
ASSERT_EQ(i, options.statistics->getTickerCount(BLOCK_CACHE_INDEX_ADD)); ASSERT_EQ(i, options.statistics->getTickerCount(BLOCK_CACHE_INDEX_ADD));
ASSERT_EQ(i, options.statistics->getTickerCount(BLOCK_CACHE_FILTER_ADD)); ASSERT_EQ(i, options.statistics->getTickerCount(BLOCK_CACHE_FILTER_ADD));
} }
ASSERT_EQ(value, Get(ToString(i))); ASSERT_EQ(value, Get(std::to_string(i)));
ASSERT_EQ(0, options.statistics->getTickerCount(BLOCK_CACHE_DATA_MISS)); ASSERT_EQ(0, options.statistics->getTickerCount(BLOCK_CACHE_DATA_MISS));
ASSERT_EQ(i, options.statistics->getTickerCount(BLOCK_CACHE_DATA_HIT)); ASSERT_EQ(i, options.statistics->getTickerCount(BLOCK_CACHE_DATA_HIT));
@ -773,12 +773,12 @@ TEST_F(DBBlockCacheTest, DynamicallyWarmCacheDuringFlush) {
std::string value(kValueSize, 'a'); std::string value(kValueSize, 'a');
for (size_t i = 1; i <= 5; i++) { for (size_t i = 1; i <= 5; i++) {
ASSERT_OK(Put(ToString(i), value)); ASSERT_OK(Put(std::to_string(i), value));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_EQ(1, ASSERT_EQ(1,
options.statistics->getAndResetTickerCount(BLOCK_CACHE_DATA_ADD)); options.statistics->getAndResetTickerCount(BLOCK_CACHE_DATA_ADD));
ASSERT_EQ(value, Get(ToString(i))); ASSERT_EQ(value, Get(std::to_string(i)));
ASSERT_EQ(0, ASSERT_EQ(0,
options.statistics->getAndResetTickerCount(BLOCK_CACHE_DATA_ADD)); options.statistics->getAndResetTickerCount(BLOCK_CACHE_DATA_ADD));
ASSERT_EQ( ASSERT_EQ(
@ -791,12 +791,12 @@ TEST_F(DBBlockCacheTest, DynamicallyWarmCacheDuringFlush) {
{{"block_based_table_factory", "{prepopulate_block_cache=kDisable;}"}})); {{"block_based_table_factory", "{prepopulate_block_cache=kDisable;}"}}));
for (size_t i = 6; i <= kNumBlocks; i++) { for (size_t i = 6; i <= kNumBlocks; i++) {
ASSERT_OK(Put(ToString(i), value)); ASSERT_OK(Put(std::to_string(i), value));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_EQ(0, ASSERT_EQ(0,
options.statistics->getAndResetTickerCount(BLOCK_CACHE_DATA_ADD)); options.statistics->getAndResetTickerCount(BLOCK_CACHE_DATA_ADD));
ASSERT_EQ(value, Get(ToString(i))); ASSERT_EQ(value, Get(std::to_string(i)));
ASSERT_EQ(1, ASSERT_EQ(1,
options.statistics->getAndResetTickerCount(BLOCK_CACHE_DATA_ADD)); options.statistics->getAndResetTickerCount(BLOCK_CACHE_DATA_ADD));
ASSERT_EQ( ASSERT_EQ(
@ -1409,7 +1409,7 @@ TEST_F(DBBlockCacheTest, CacheEntryRoleStats) {
for (size_t i = 0; i < kNumCacheEntryRoles; ++i) { for (size_t i = 0; i < kNumCacheEntryRoles; ++i) {
auto role = static_cast<CacheEntryRole>(i); auto role = static_cast<CacheEntryRole>(i);
EXPECT_EQ(ToString(expected[i]), EXPECT_EQ(std::to_string(expected[i]),
values[BlockCacheEntryStatsMapKeys::EntryCount(role)]); values[BlockCacheEntryStatsMapKeys::EntryCount(role)]);
} }
@ -1422,7 +1422,7 @@ TEST_F(DBBlockCacheTest, CacheEntryRoleStats) {
// re-scanning stats, but not totally aggressive. // re-scanning stats, but not totally aggressive.
// Within some time window, we will get cached entry stats // Within some time window, we will get cached entry stats
env_->MockSleepForSeconds(1); env_->MockSleepForSeconds(1);
EXPECT_EQ(ToString(prev_expected[static_cast<size_t>( EXPECT_EQ(std::to_string(prev_expected[static_cast<size_t>(
CacheEntryRole::kWriteBuffer)]), CacheEntryRole::kWriteBuffer)]),
values[BlockCacheEntryStatsMapKeys::EntryCount( values[BlockCacheEntryStatsMapKeys::EntryCount(
CacheEntryRole::kWriteBuffer)]); CacheEntryRole::kWriteBuffer)]);
@ -1432,7 +1432,7 @@ TEST_F(DBBlockCacheTest, CacheEntryRoleStats) {
ASSERT_TRUE(db_->GetMapProperty(DB::Properties::kBlockCacheEntryStats, ASSERT_TRUE(db_->GetMapProperty(DB::Properties::kBlockCacheEntryStats,
&values)); &values));
EXPECT_EQ( EXPECT_EQ(
ToString( std::to_string(
expected[static_cast<size_t>(CacheEntryRole::kWriteBuffer)]), expected[static_cast<size_t>(CacheEntryRole::kWriteBuffer)]),
values[BlockCacheEntryStatsMapKeys::EntryCount( values[BlockCacheEntryStatsMapKeys::EntryCount(
CacheEntryRole::kWriteBuffer)]); CacheEntryRole::kWriteBuffer)]);
@ -1640,7 +1640,7 @@ TEST_P(DBBlockCacheKeyTest, StableCacheKeys) {
SstFileWriter sst_file_writer(EnvOptions(), options); SstFileWriter sst_file_writer(EnvOptions(), options);
std::vector<std::string> external; std::vector<std::string> external;
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
std::string f = dbname_ + "/external" + ToString(i) + ".sst"; std::string f = dbname_ + "/external" + std::to_string(i) + ".sst";
external.push_back(f); external.push_back(f);
ASSERT_OK(sst_file_writer.Open(f)); ASSERT_OK(sst_file_writer.Open(f));
ASSERT_OK(sst_file_writer.Put(Key(key_count), "abc")); ASSERT_OK(sst_file_writer.Put(Key(key_count), "abc"));
@ -1724,7 +1724,7 @@ class CacheKeyTest : public testing::Test {
// Like SemiStructuredUniqueIdGen::GenerateNext // Like SemiStructuredUniqueIdGen::GenerateNext
tp_.db_session_id = EncodeSessionId(base_session_upper_, tp_.db_session_id = EncodeSessionId(base_session_upper_,
base_session_lower_ ^ session_counter_); base_session_lower_ ^ session_counter_);
tp_.db_id = ToString(db_id_); tp_.db_id = std::to_string(db_id_);
tp_.orig_file_number = file_number_; tp_.orig_file_number = file_number_;
bool is_stable; bool is_stable;
std::string cur_session_id = ""; // ignored std::string cur_session_id = ""; // ignored

View File

@ -858,7 +858,7 @@ TEST_F(DBBloomFilterTest, BloomFilterCompatibility) {
options.table_factory.reset(NewBlockBasedTableFactory(table_options)); options.table_factory.reset(NewBlockBasedTableFactory(table_options));
Reopen(options); Reopen(options);
std::string prefix = ToString(i) + "_"; std::string prefix = std::to_string(i) + "_";
ASSERT_OK(Put(prefix + "A", "val")); ASSERT_OK(Put(prefix + "A", "val"));
ASSERT_OK(Put(prefix + "Z", "val")); ASSERT_OK(Put(prefix + "Z", "val"));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
@ -873,7 +873,7 @@ TEST_F(DBBloomFilterTest, BloomFilterCompatibility) {
options.table_factory.reset(NewBlockBasedTableFactory(table_options)); options.table_factory.reset(NewBlockBasedTableFactory(table_options));
Reopen(options); Reopen(options);
for (size_t j = 0; j < kCompatibilityConfigs.size(); ++j) { for (size_t j = 0; j < kCompatibilityConfigs.size(); ++j) {
std::string prefix = ToString(j) + "_"; std::string prefix = std::to_string(j) + "_";
ASSERT_EQ("val", Get(prefix + "A")); // Filter positive ASSERT_EQ("val", Get(prefix + "A")); // Filter positive
ASSERT_EQ("val", Get(prefix + "Z")); // Filter positive ASSERT_EQ("val", Get(prefix + "Z")); // Filter positive
// Filter negative, with high probability // Filter negative, with high probability
@ -1713,11 +1713,11 @@ class TestingContextCustomFilterPolicy
test_report_ += test_report_ +=
OptionsHelper::compaction_style_to_string[context.compaction_style]; OptionsHelper::compaction_style_to_string[context.compaction_style];
test_report_ += ",n="; test_report_ += ",n=";
test_report_ += ROCKSDB_NAMESPACE::ToString(context.num_levels); test_report_ += std::to_string(context.num_levels);
test_report_ += ",l="; test_report_ += ",l=";
test_report_ += ROCKSDB_NAMESPACE::ToString(context.level_at_creation); test_report_ += std::to_string(context.level_at_creation);
test_report_ += ",b="; test_report_ += ",b=";
test_report_ += ROCKSDB_NAMESPACE::ToString(int{context.is_bottommost}); test_report_ += std::to_string(int{context.is_bottommost});
test_report_ += ",r="; test_report_ += ",r=";
test_report_ += table_file_creation_reason_to_string[context.reason]; test_report_ += table_file_creation_reason_to_string[context.reason];
test_report_ += "\n"; test_report_ += "\n";

View File

@ -454,7 +454,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilterDeletesAll) {
// put some data // put some data
for (int table = 0; table < 4; ++table) { for (int table = 0; table < 4; ++table) {
for (int i = 0; i < 10 + table; ++i) { for (int i = 0; i < 10 + table; ++i) {
ASSERT_OK(Put(ToString(table * 100 + i), "val")); ASSERT_OK(Put(std::to_string(table * 100 + i), "val"));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -755,7 +755,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilterContextCfId) {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
// Compaction filters aplies to all records, regardless snapshots. // Compaction filters aplies to all records, regardless snapshots.
TEST_F(DBTestCompactionFilter, CompactionFilterIgnoreSnapshot) { TEST_F(DBTestCompactionFilter, CompactionFilterIgnoreSnapshot) {
std::string five = ToString(5); std::string five = std::to_string(5);
Options options = CurrentOptions(); Options options = CurrentOptions();
options.compaction_filter_factory = std::make_shared<DeleteISFilterFactory>(); options.compaction_filter_factory = std::make_shared<DeleteISFilterFactory>();
options.disable_auto_compactions = true; options.disable_auto_compactions = true;
@ -766,7 +766,7 @@ TEST_F(DBTestCompactionFilter, CompactionFilterIgnoreSnapshot) {
const Snapshot* snapshot = nullptr; const Snapshot* snapshot = nullptr;
for (int table = 0; table < 4; ++table) { for (int table = 0; table < 4; ++table) {
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
ASSERT_OK(Put(ToString(table * 100 + i), "val")); ASSERT_OK(Put(std::to_string(table * 100 + i), "val"));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());

View File

@ -2817,7 +2817,7 @@ TEST_P(DBCompactionTestWithParam, DISABLED_CompactFilesOnLevelCompaction) {
Random rnd(301); Random rnd(301);
for (int key = 64 * kEntriesPerBuffer; key >= 0; --key) { for (int key = 64 * kEntriesPerBuffer; key >= 0; --key) {
ASSERT_OK(Put(1, ToString(key), rnd.RandomString(kTestValueSize))); ASSERT_OK(Put(1, std::to_string(key), rnd.RandomString(kTestValueSize)));
} }
ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable(handles_[1])); ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable(handles_[1]));
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -2849,7 +2849,7 @@ TEST_P(DBCompactionTestWithParam, DISABLED_CompactFilesOnLevelCompaction) {
// make sure all key-values are still there. // make sure all key-values are still there.
for (int key = 64 * kEntriesPerBuffer; key >= 0; --key) { for (int key = 64 * kEntriesPerBuffer; key >= 0; --key) {
ASSERT_NE(Get(1, ToString(key)), "NOT_FOUND"); ASSERT_NE(Get(1, std::to_string(key)), "NOT_FOUND");
} }
} }
@ -4668,9 +4668,9 @@ TEST_F(DBCompactionTest, CompactRangeSkipFlushAfterDelay) {
}); });
TEST_SYNC_POINT("DBCompactionTest::CompactRangeSkipFlushAfterDelay:PreFlush"); TEST_SYNC_POINT("DBCompactionTest::CompactRangeSkipFlushAfterDelay:PreFlush");
ASSERT_OK(Put(ToString(0), rnd.RandomString(1024))); ASSERT_OK(Put(std::to_string(0), rnd.RandomString(1024)));
ASSERT_OK(dbfull()->Flush(flush_opts)); ASSERT_OK(dbfull()->Flush(flush_opts));
ASSERT_OK(Put(ToString(0), rnd.RandomString(1024))); ASSERT_OK(Put(std::to_string(0), rnd.RandomString(1024)));
TEST_SYNC_POINT("DBCompactionTest::CompactRangeSkipFlushAfterDelay:PostFlush"); TEST_SYNC_POINT("DBCompactionTest::CompactRangeSkipFlushAfterDelay:PostFlush");
manual_compaction_thread.join(); manual_compaction_thread.join();
@ -4679,7 +4679,7 @@ TEST_F(DBCompactionTest, CompactRangeSkipFlushAfterDelay) {
std::string num_keys_in_memtable; std::string num_keys_in_memtable;
ASSERT_TRUE(db_->GetProperty(DB::Properties::kNumEntriesActiveMemTable, ASSERT_TRUE(db_->GetProperty(DB::Properties::kNumEntriesActiveMemTable,
&num_keys_in_memtable)); &num_keys_in_memtable));
ASSERT_EQ(ToString(1), num_keys_in_memtable); ASSERT_EQ(std::to_string(1), num_keys_in_memtable);
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
} }
@ -4828,7 +4828,7 @@ TEST_F(DBCompactionTest, SubcompactionEvent) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 10 + j; int key_id = i * 10 + j;
ASSERT_OK(Put(Key(key_id), "value" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -4838,7 +4838,7 @@ TEST_F(DBCompactionTest, SubcompactionEvent) {
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int key_id = i * 20 + j * 2; int key_id = i * 20 + j * 2;
ASSERT_OK(Put(Key(key_id), "value" + ToString(key_id))); ASSERT_OK(Put(Key(key_id), "value" + std::to_string(key_id)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -5830,7 +5830,7 @@ TEST_P(DBCompactionTestWithBottommostParam, SequenceKeysManualCompaction) {
} }
ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable()); ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
ASSERT_EQ(ToString(kSstNum), FilesPerLevel(0)); ASSERT_EQ(std::to_string(kSstNum), FilesPerLevel(0));
auto cro = CompactRangeOptions(); auto cro = CompactRangeOptions();
cro.bottommost_level_compaction = bottommost_level_compaction_; cro.bottommost_level_compaction = bottommost_level_compaction_;
@ -5843,7 +5843,7 @@ TEST_P(DBCompactionTestWithBottommostParam, SequenceKeysManualCompaction) {
ASSERT_EQ("0,1", FilesPerLevel(0)); ASSERT_EQ("0,1", FilesPerLevel(0));
} else { } else {
// Just trivial move from level 0 -> 1 // Just trivial move from level 0 -> 1
ASSERT_EQ("0," + ToString(kSstNum), FilesPerLevel(0)); ASSERT_EQ("0," + std::to_string(kSstNum), FilesPerLevel(0));
} }
} }
@ -7174,7 +7174,7 @@ TEST_F(DBCompactionTest, DisableManualCompactionThreadQueueFull) {
ASSERT_OK(Put(Key(2), "value2")); ASSERT_OK(Put(Key(2), "value2"));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
ASSERT_EQ(ToString(kNumL0Files + (kNumL0Files / 2)), FilesPerLevel(0)); ASSERT_EQ(std::to_string(kNumL0Files + (kNumL0Files / 2)), FilesPerLevel(0));
db_->DisableManualCompaction(); db_->DisableManualCompaction();
@ -7231,7 +7231,7 @@ TEST_F(DBCompactionTest, DisableManualCompactionThreadQueueFullDBClose) {
ASSERT_OK(Put(Key(2), "value2")); ASSERT_OK(Put(Key(2), "value2"));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
ASSERT_EQ(ToString(kNumL0Files + (kNumL0Files / 2)), FilesPerLevel(0)); ASSERT_EQ(std::to_string(kNumL0Files + (kNumL0Files / 2)), FilesPerLevel(0));
db_->DisableManualCompaction(); db_->DisableManualCompaction();
@ -7291,7 +7291,7 @@ TEST_F(DBCompactionTest, DBCloseWithManualCompaction) {
ASSERT_OK(Put(Key(2), "value2")); ASSERT_OK(Put(Key(2), "value2"));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
ASSERT_EQ(ToString(kNumL0Files + (kNumL0Files / 2)), FilesPerLevel(0)); ASSERT_EQ(std::to_string(kNumL0Files + (kNumL0Files / 2)), FilesPerLevel(0));
// Close DB with manual compaction and auto triggered compaction in the queue. // Close DB with manual compaction and auto triggered compaction in the queue.
auto s = db_->Close(); auto s = db_->Close();

View File

@ -849,7 +849,8 @@ void DBImpl::PersistStats() {
if (stats_slice_.find(stat.first) != stats_slice_.end()) { if (stats_slice_.find(stat.first) != stats_slice_.end()) {
uint64_t delta = stat.second - stats_slice_[stat.first]; uint64_t delta = stat.second - stats_slice_[stat.first];
s = batch.Put(persist_stats_cf_handle_, s = batch.Put(persist_stats_cf_handle_,
Slice(key, std::min(100, length)), ToString(delta)); Slice(key, std::min(100, length)),
std::to_string(delta));
} }
} }
} }
@ -3355,7 +3356,7 @@ bool DBImpl::GetProperty(ColumnFamilyHandle* column_family,
bool ret_value = bool ret_value =
GetIntPropertyInternal(cfd, *property_info, false, &int_value); GetIntPropertyInternal(cfd, *property_info, false, &int_value);
if (ret_value) { if (ret_value) {
*value = ToString(int_value); *value = std::to_string(int_value);
} }
return ret_value; return ret_value;
} else if (property_info->handle_string) { } else if (property_info->handle_string) {
@ -3990,8 +3991,8 @@ Status DBImpl::CheckConsistency() {
} else if (fsize != md.size) { } else if (fsize != md.size) {
corruption_messages += "Sst file size mismatch: " + file_path + corruption_messages += "Sst file size mismatch: " + file_path +
". Size recorded in manifest " + ". Size recorded in manifest " +
ToString(md.size) + ", actual size " + std::to_string(md.size) + ", actual size " +
ToString(fsize) + "\n"; std::to_string(fsize) + "\n";
} }
} }
} }

View File

@ -760,11 +760,11 @@ Status DBImpl::PersistentStatsProcessFormatVersion() {
WriteBatch batch; WriteBatch batch;
if (s.ok()) { if (s.ok()) {
s = batch.Put(persist_stats_cf_handle_, kFormatVersionKeyString, s = batch.Put(persist_stats_cf_handle_, kFormatVersionKeyString,
ToString(kStatsCFCurrentFormatVersion)); std::to_string(kStatsCFCurrentFormatVersion));
} }
if (s.ok()) { if (s.ok()) {
s = batch.Put(persist_stats_cf_handle_, kCompatibleVersionKeyString, s = batch.Put(persist_stats_cf_handle_, kCompatibleVersionKeyString,
ToString(kStatsCFCompatibleFormatVersion)); std::to_string(kStatsCFCompatibleFormatVersion));
} }
if (s.ok()) { if (s.ok()) {
WriteOptions wo; WriteOptions wo;

View File

@ -414,7 +414,7 @@ TEST_F(DBIteratorStressTest, StressTest) {
a /= 10; a /= 10;
++len; ++len;
} }
std::string s = ToString(rnd.Next() % static_cast<uint64_t>(max_key)); std::string s = std::to_string(rnd.Next() % static_cast<uint64_t>(max_key));
s.insert(0, len - (int)s.size(), '0'); s.insert(0, len - (int)s.size(), '0');
return s; return s;
}; };
@ -444,12 +444,13 @@ TEST_F(DBIteratorStressTest, StressTest) {
for (double mutation_probability : {0.01, 0.5}) { for (double mutation_probability : {0.01, 0.5}) {
for (double target_hidden_fraction : {0.1, 0.5}) { for (double target_hidden_fraction : {0.1, 0.5}) {
std::string trace_str = std::string trace_str =
"entries: " + ToString(num_entries) + "entries: " + std::to_string(num_entries) +
", key_space: " + ToString(key_space) + ", key_space: " + std::to_string(key_space) +
", error_probability: " + ToString(error_probability) + ", error_probability: " + std::to_string(error_probability) +
", mutation_probability: " + ToString(mutation_probability) + ", mutation_probability: " +
std::to_string(mutation_probability) +
", target_hidden_fraction: " + ", target_hidden_fraction: " +
ToString(target_hidden_fraction); std::to_string(target_hidden_fraction);
SCOPED_TRACE(trace_str); SCOPED_TRACE(trace_str);
if (trace) { if (trace) {
std::cout << trace_str << std::endl; std::cout << trace_str << std::endl;
@ -470,7 +471,7 @@ TEST_F(DBIteratorStressTest, StressTest) {
types[rnd.Next() % (sizeof(types) / sizeof(types[0]))]; types[rnd.Next() % (sizeof(types) / sizeof(types[0]))];
} }
e.sequence = i; e.sequence = i;
e.value = "v" + ToString(i); e.value = "v" + std::to_string(i);
ParsedInternalKey internal_key(e.key, e.sequence, e.type); ParsedInternalKey internal_key(e.key, e.sequence, e.type);
AppendInternalKey(&e.ikey, internal_key); AppendInternalKey(&e.ikey, internal_key);

View File

@ -766,7 +766,7 @@ TEST_F(DBIteratorTest, DBIteratorUseSkip) {
internal_iter->AddMerge("b", "merge_1"); internal_iter->AddMerge("b", "merge_1");
internal_iter->AddMerge("a", "merge_2"); internal_iter->AddMerge("a", "merge_2");
for (size_t k = 0; k < 200; ++k) { for (size_t k = 0; k < 200; ++k) {
internal_iter->AddPut("c", ToString(k)); internal_iter->AddPut("c", std::to_string(k));
} }
internal_iter->Finish(); internal_iter->Finish();
@ -780,7 +780,7 @@ TEST_F(DBIteratorTest, DBIteratorUseSkip) {
ASSERT_TRUE(db_iter->Valid()); ASSERT_TRUE(db_iter->Valid());
ASSERT_EQ(db_iter->key().ToString(), "c"); ASSERT_EQ(db_iter->key().ToString(), "c");
ASSERT_EQ(db_iter->value().ToString(), ToString(i)); ASSERT_EQ(db_iter->value().ToString(), std::to_string(i));
db_iter->Prev(); db_iter->Prev();
ASSERT_TRUE(db_iter->Valid()); ASSERT_TRUE(db_iter->Valid());
@ -925,11 +925,11 @@ TEST_F(DBIteratorTest, DBIteratorUseSkip) {
internal_iter->AddMerge("b", "merge_1"); internal_iter->AddMerge("b", "merge_1");
internal_iter->AddMerge("a", "merge_2"); internal_iter->AddMerge("a", "merge_2");
for (size_t k = 0; k < 200; ++k) { for (size_t k = 0; k < 200; ++k) {
internal_iter->AddPut("d", ToString(k)); internal_iter->AddPut("d", std::to_string(k));
} }
for (size_t k = 0; k < 200; ++k) { for (size_t k = 0; k < 200; ++k) {
internal_iter->AddPut("c", ToString(k)); internal_iter->AddPut("c", std::to_string(k));
} }
internal_iter->Finish(); internal_iter->Finish();
@ -942,7 +942,7 @@ TEST_F(DBIteratorTest, DBIteratorUseSkip) {
ASSERT_TRUE(db_iter->Valid()); ASSERT_TRUE(db_iter->Valid());
ASSERT_EQ(db_iter->key().ToString(), "d"); ASSERT_EQ(db_iter->key().ToString(), "d");
ASSERT_EQ(db_iter->value().ToString(), ToString(i)); ASSERT_EQ(db_iter->value().ToString(), std::to_string(i));
db_iter->Prev(); db_iter->Prev();
ASSERT_TRUE(db_iter->Valid()); ASSERT_TRUE(db_iter->Valid());
@ -966,7 +966,7 @@ TEST_F(DBIteratorTest, DBIteratorUseSkip) {
internal_iter->AddMerge("b", "b"); internal_iter->AddMerge("b", "b");
internal_iter->AddMerge("a", "a"); internal_iter->AddMerge("a", "a");
for (size_t k = 0; k < 200; ++k) { for (size_t k = 0; k < 200; ++k) {
internal_iter->AddMerge("c", ToString(k)); internal_iter->AddMerge("c", std::to_string(k));
} }
internal_iter->Finish(); internal_iter->Finish();
@ -981,7 +981,7 @@ TEST_F(DBIteratorTest, DBIteratorUseSkip) {
ASSERT_EQ(db_iter->key().ToString(), "c"); ASSERT_EQ(db_iter->key().ToString(), "c");
std::string merge_result = "0"; std::string merge_result = "0";
for (size_t j = 1; j <= i; ++j) { for (size_t j = 1; j <= i; ++j) {
merge_result += "," + ToString(j); merge_result += "," + std::to_string(j);
} }
ASSERT_EQ(db_iter->value().ToString(), merge_result); ASSERT_EQ(db_iter->value().ToString(), merge_result);
@ -3156,7 +3156,7 @@ TEST_F(DBIteratorTest, ReverseToForwardWithDisappearingKeys) {
internal_iter->AddPut("a", "A"); internal_iter->AddPut("a", "A");
internal_iter->AddPut("b", "B"); internal_iter->AddPut("b", "B");
for (int i = 0; i < 100; ++i) { for (int i = 0; i < 100; ++i) {
internal_iter->AddPut("c" + ToString(i), ""); internal_iter->AddPut("c" + std::to_string(i), "");
} }
internal_iter->Finish(); internal_iter->Finish();

View File

@ -3160,7 +3160,7 @@ TEST_F(DBIteratorWithReadCallbackTest, ReadCallback) {
uint64_t num_versions = uint64_t num_versions =
CurrentOptions().max_sequential_skip_in_iterations + 10; CurrentOptions().max_sequential_skip_in_iterations + 10;
for (uint64_t i = 0; i < num_versions; i++) { for (uint64_t i = 0; i < num_versions; i++) {
ASSERT_OK(Put("bar", ToString(i))); ASSERT_OK(Put("bar", std::to_string(i)));
} }
SequenceNumber seq3 = db_->GetLatestSequenceNumber(); SequenceNumber seq3 = db_->GetLatestSequenceNumber();
TestReadCallback callback2(seq3); TestReadCallback callback2(seq3);
@ -3189,7 +3189,7 @@ TEST_F(DBIteratorWithReadCallbackTest, ReadCallback) {
ASSERT_TRUE(iter->Valid()); ASSERT_TRUE(iter->Valid());
ASSERT_OK(iter->status()); ASSERT_OK(iter->status());
ASSERT_EQ("bar", iter->key()); ASSERT_EQ("bar", iter->key());
ASSERT_EQ(ToString(num_versions - 1), iter->value()); ASSERT_EQ(std::to_string(num_versions - 1), iter->value());
delete iter; delete iter;
} }

View File

@ -187,7 +187,7 @@ TEST_F(DBTestXactLogIterator, TransactionLogIteratorCorruptedLog) {
DestroyAndReopen(options); DestroyAndReopen(options);
for (int i = 0; i < 1024; i++) { for (int i = 0; i < 1024; i++) {
ASSERT_OK(Put("key" + ToString(i), DummyString(10))); ASSERT_OK(Put("key" + std::to_string(i), DummyString(10)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
@ -263,20 +263,20 @@ TEST_F(DBTestXactLogIterator, TransactionLogIteratorBlobs) {
struct Handler : public WriteBatch::Handler { struct Handler : public WriteBatch::Handler {
std::string seen; std::string seen;
Status PutCF(uint32_t cf, const Slice& key, const Slice& value) override { Status PutCF(uint32_t cf, const Slice& key, const Slice& value) override {
seen += "Put(" + ToString(cf) + ", " + key.ToString() + ", " + seen += "Put(" + std::to_string(cf) + ", " + key.ToString() + ", " +
ToString(value.size()) + ")"; std::to_string(value.size()) + ")";
return Status::OK(); return Status::OK();
} }
Status MergeCF(uint32_t cf, const Slice& key, const Slice& value) override { Status MergeCF(uint32_t cf, const Slice& key, const Slice& value) override {
seen += "Merge(" + ToString(cf) + ", " + key.ToString() + ", " + seen += "Merge(" + std::to_string(cf) + ", " + key.ToString() + ", " +
ToString(value.size()) + ")"; std::to_string(value.size()) + ")";
return Status::OK(); return Status::OK();
} }
void LogData(const Slice& blob) override { void LogData(const Slice& blob) override {
seen += "LogData(" + blob.ToString() + ")"; seen += "LogData(" + blob.ToString() + ")";
} }
Status DeleteCF(uint32_t cf, const Slice& key) override { Status DeleteCF(uint32_t cf, const Slice& key) override {
seen += "Delete(" + ToString(cf) + ", " + key.ToString() + ")"; seen += "Delete(" + std::to_string(cf) + ", " + key.ToString() + ")";
return Status::OK(); return Status::OK();
} }
} handler; } handler;

View File

@ -171,7 +171,7 @@ TEST_F(DBMemTableTest, DuplicateSeq) {
if (!insert_dup) { if (!insert_dup) {
seq++; seq++;
} }
Status s = mem->Add(seq, kTypeValue, "foo", "value" + ToString(seq), Status s = mem->Add(seq, kTypeValue, "foo", "value" + std::to_string(seq),
nullptr /* kv_prot_info */); nullptr /* kv_prot_info */);
if (insert_dup) { if (insert_dup) {
ASSERT_TRUE(s.IsTryAgain()); ASSERT_TRUE(s.IsTryAgain());

View File

@ -424,8 +424,8 @@ TEST_F(DBOptionsTest, WritableFileMaxBufferSize) {
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
int i = 0; int i = 0;
for (; i < 3; i++) { for (; i < 3; i++) {
ASSERT_OK(Put("foo", ToString(i))); ASSERT_OK(Put("foo", std::to_string(i)));
ASSERT_OK(Put("bar", ToString(i))); ASSERT_OK(Put("bar", std::to_string(i)));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -442,8 +442,8 @@ TEST_F(DBOptionsTest, WritableFileMaxBufferSize) {
dbfull()->GetDBOptions().writable_file_max_buffer_size); dbfull()->GetDBOptions().writable_file_max_buffer_size);
i = 0; i = 0;
for (; i < 3; i++) { for (; i < 3; i++) {
ASSERT_OK(Put("foo", ToString(i))); ASSERT_OK(Put("foo", std::to_string(i)));
ASSERT_OK(Put("bar", ToString(i))); ASSERT_OK(Put("bar", std::to_string(i)));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -573,8 +573,8 @@ TEST_F(DBOptionsTest, SetOptionsMayTriggerCompaction) {
Reopen(options); Reopen(options);
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
// Need to insert two keys to avoid trivial move. // Need to insert two keys to avoid trivial move.
ASSERT_OK(Put("foo", ToString(i))); ASSERT_OK(Put("foo", std::to_string(i)));
ASSERT_OK(Put("bar", ToString(i))); ASSERT_OK(Put("bar", std::to_string(i)));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
ASSERT_EQ("3", FilesPerLevel()); ASSERT_EQ("3", FilesPerLevel());
@ -717,8 +717,8 @@ TEST_F(DBOptionsTest, SetStatsDumpPeriodSec) {
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
unsigned int num = rand() % 5000 + 1; unsigned int num = rand() % 5000 + 1;
ASSERT_OK( ASSERT_OK(dbfull()->SetDBOptions(
dbfull()->SetDBOptions({{"stats_dump_period_sec", ToString(num)}})); {{"stats_dump_period_sec", std::to_string(num)}}));
ASSERT_EQ(num, dbfull()->GetDBOptions().stats_dump_period_sec); ASSERT_EQ(num, dbfull()->GetDBOptions().stats_dump_period_sec);
} }
Close(); Close();
@ -909,7 +909,7 @@ TEST_F(DBOptionsTest, SetFIFOCompactionOptions) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
// Generate and flush a file about 10KB. // Generate and flush a file about 10KB.
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
ASSERT_OK(Put(ToString(i * 20 + j), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 20 + j), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -940,7 +940,7 @@ TEST_F(DBOptionsTest, SetFIFOCompactionOptions) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
// Generate and flush a file about 10KB. // Generate and flush a file about 10KB.
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
ASSERT_OK(Put(ToString(i * 20 + j), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 20 + j), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -972,7 +972,7 @@ TEST_F(DBOptionsTest, SetFIFOCompactionOptions) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
// Generate and flush a file about 10KB. // Generate and flush a file about 10KB.
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
ASSERT_OK(Put(ToString(i * 20 + j), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 20 + j), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -1036,7 +1036,7 @@ TEST_F(DBOptionsTest, FIFOTtlBackwardCompatible) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
// Generate and flush a file about 10KB. // Generate and flush a file about 10KB.
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
ASSERT_OK(Put(ToString(i * 20 + j), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 20 + j), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }

View File

@ -593,8 +593,8 @@ TEST_F(DBPropertiesTest, AggregatedTablePropertiesAtLevel) {
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr)); ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
ResetTableProperties(&sum_tp); ResetTableProperties(&sum_tp);
for (int level = 0; level < kMaxLevel; ++level) { for (int level = 0; level < kMaxLevel; ++level) {
db_->GetProperty( db_->GetProperty(DB::Properties::kAggregatedTablePropertiesAtLevel +
DB::Properties::kAggregatedTablePropertiesAtLevel + ToString(level), std::to_string(level),
&level_tp_strings[level]); &level_tp_strings[level]);
ParseTablePropertiesString(level_tp_strings[level], &level_tps[level]); ParseTablePropertiesString(level_tp_strings[level], &level_tps[level]);
sum_tp.data_size += level_tps[level].data_size; sum_tp.data_size += level_tps[level].data_size;
@ -1091,7 +1091,7 @@ TEST_F(DBPropertiesTest, EstimateCompressionRatio) {
for (int j = 0; j < kNumEntriesPerFile; ++j) { for (int j = 0; j < kNumEntriesPerFile; ++j) {
// Put common data ("key") at end to prevent delta encoding from // Put common data ("key") at end to prevent delta encoding from
// compressing the key effectively // compressing the key effectively
std::string key = ToString(i) + ToString(j) + "key"; std::string key = std::to_string(i) + std::to_string(j) + "key";
ASSERT_OK(dbfull()->Put(WriteOptions(), key, kVal)); ASSERT_OK(dbfull()->Put(WriteOptions(), key, kVal));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
@ -1185,7 +1185,7 @@ class CountingDeleteTabPropCollector : public TablePropertiesCollector {
Status Finish(UserCollectedProperties* properties) override { Status Finish(UserCollectedProperties* properties) override {
*properties = *properties =
UserCollectedProperties{{"num_delete", ToString(num_deletes_)}}; UserCollectedProperties{{"num_delete", std::to_string(num_deletes_)}};
return Status::OK(); return Status::OK();
} }
@ -1215,7 +1215,7 @@ class BlockCountingTablePropertiesCollector : public TablePropertiesCollector {
Status Finish(UserCollectedProperties* properties) override { Status Finish(UserCollectedProperties* properties) override {
(*properties)[kNumSampledBlocksPropertyName] = (*properties)[kNumSampledBlocksPropertyName] =
ToString(num_sampled_blocks_); std::to_string(num_sampled_blocks_);
return Status::OK(); return Status::OK();
} }
@ -1235,7 +1235,7 @@ class BlockCountingTablePropertiesCollector : public TablePropertiesCollector {
UserCollectedProperties GetReadableProperties() const override { UserCollectedProperties GetReadableProperties() const override {
return UserCollectedProperties{ return UserCollectedProperties{
{kNumSampledBlocksPropertyName, ToString(num_sampled_blocks_)}, {kNumSampledBlocksPropertyName, std::to_string(num_sampled_blocks_)},
}; };
} }
@ -1272,7 +1272,8 @@ TEST_F(DBPropertiesTest, GetUserDefinedTableProperties) {
// Create 4 tables // Create 4 tables
for (int table = 0; table < 4; ++table) { for (int table = 0; table < 4; ++table) {
for (int i = 0; i < 10 + table; ++i) { for (int i = 0; i < 10 + table; ++i) {
ASSERT_OK(db_->Put(WriteOptions(), ToString(table * 100 + i), "val")); ASSERT_OK(
db_->Put(WriteOptions(), std::to_string(table * 100 + i), "val"));
} }
ASSERT_OK(db_->Flush(FlushOptions())); ASSERT_OK(db_->Flush(FlushOptions()));
} }
@ -1312,7 +1313,7 @@ TEST_F(DBPropertiesTest, UserDefinedTablePropertiesContext) {
// Create 2 files // Create 2 files
for (int table = 0; table < 2; ++table) { for (int table = 0; table < 2; ++table) {
for (int i = 0; i < 10 + table; ++i) { for (int i = 0; i < 10 + table; ++i) {
ASSERT_OK(Put(1, ToString(table * 100 + i), "val")); ASSERT_OK(Put(1, std::to_string(table * 100 + i), "val"));
} }
ASSERT_OK(Flush(1)); ASSERT_OK(Flush(1));
} }
@ -1322,7 +1323,7 @@ TEST_F(DBPropertiesTest, UserDefinedTablePropertiesContext) {
// Trigger automatic compactions. // Trigger automatic compactions.
for (int table = 0; table < 3; ++table) { for (int table = 0; table < 3; ++table) {
for (int i = 0; i < 10 + table; ++i) { for (int i = 0; i < 10 + table; ++i) {
ASSERT_OK(Put(1, ToString(table * 100 + i), "val")); ASSERT_OK(Put(1, std::to_string(table * 100 + i), "val"));
} }
ASSERT_OK(Flush(1)); ASSERT_OK(Flush(1));
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -1339,7 +1340,7 @@ TEST_F(DBPropertiesTest, UserDefinedTablePropertiesContext) {
// Create 4 tables in default column family // Create 4 tables in default column family
for (int table = 0; table < 2; ++table) { for (int table = 0; table < 2; ++table) {
for (int i = 0; i < 10 + table; ++i) { for (int i = 0; i < 10 + table; ++i) {
ASSERT_OK(Put(ToString(table * 100 + i), "val")); ASSERT_OK(Put(std::to_string(table * 100 + i), "val"));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -1349,7 +1350,7 @@ TEST_F(DBPropertiesTest, UserDefinedTablePropertiesContext) {
// Trigger automatic compactions. // Trigger automatic compactions.
for (int table = 0; table < 3; ++table) { for (int table = 0; table < 3; ++table) {
for (int i = 0; i < 10 + table; ++i) { for (int i = 0; i < 10 + table; ++i) {
ASSERT_OK(Put(ToString(table * 100 + i), "val")); ASSERT_OK(Put(std::to_string(table * 100 + i), "val"));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -1545,7 +1546,7 @@ TEST_F(DBPropertiesTest, BlockAddForCompressionSampling) {
user_props.end()); user_props.end());
ASSERT_EQ(user_props.at(BlockCountingTablePropertiesCollector:: ASSERT_EQ(user_props.at(BlockCountingTablePropertiesCollector::
kNumSampledBlocksPropertyName), kNumSampledBlocksPropertyName),
ToString(sample_for_compression ? 1 : 0)); std::to_string(sample_for_compression ? 1 : 0));
} }
} }
} }
@ -1742,11 +1743,11 @@ TEST_F(DBPropertiesTest, SstFilesSize) {
Reopen(options); Reopen(options);
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
ASSERT_OK(Put("key" + ToString(i), std::string(1000, 'v'))); ASSERT_OK(Put("key" + std::to_string(i), std::string(1000, 'v')));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
ASSERT_OK(Delete("key" + ToString(i))); ASSERT_OK(Delete("key" + std::to_string(i)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
uint64_t sst_size; uint64_t sst_size;

View File

@ -190,9 +190,10 @@ TEST_F(DBRangeDelTest, MaxCompactionBytesCutsOutputFiles) {
ASSERT_EQ(0, NumTableFilesAtLevel(0)); ASSERT_EQ(0, NumTableFilesAtLevel(0));
ASSERT_EQ(NumTableFilesAtLevel(2), 2); ASSERT_EQ(NumTableFilesAtLevel(2), 2);
ASSERT_OK(db_->SetOptions( ASSERT_OK(
db_->DefaultColumnFamily(), db_->SetOptions(db_->DefaultColumnFamily(),
{{"target_file_size_base", ToString(100 * opts.max_compaction_bytes)}})); {{"target_file_size_base",
std::to_string(100 * opts.max_compaction_bytes)}}));
// It spans the whole key-range, thus will be included in all output files // It spans the whole key-range, thus will be included in all output files
ASSERT_OK(db_->DeleteRange(WriteOptions(), db_->DefaultColumnFamily(), ASSERT_OK(db_->DeleteRange(WriteOptions(), db_->DefaultColumnFamily(),

View File

@ -212,20 +212,20 @@ TEST_F(DBSecondaryTest, InternalCompactionMultiLevels) {
const int kRangeL2 = 10; const int kRangeL2 = 10;
const int kRangeL1 = 30; const int kRangeL1 = 30;
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
ASSERT_OK(Put(Key(i * kRangeL2), "value" + ToString(i))); ASSERT_OK(Put(Key(i * kRangeL2), "value" + std::to_string(i)));
ASSERT_OK(Put(Key((i + 1) * kRangeL2 - 1), "value" + ToString(i))); ASSERT_OK(Put(Key((i + 1) * kRangeL2 - 1), "value" + std::to_string(i)));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
MoveFilesToLevel(2); MoveFilesToLevel(2);
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
ASSERT_OK(Put(Key(i * kRangeL1), "value" + ToString(i))); ASSERT_OK(Put(Key(i * kRangeL1), "value" + std::to_string(i)));
ASSERT_OK(Put(Key((i + 1) * kRangeL1 - 1), "value" + ToString(i))); ASSERT_OK(Put(Key((i + 1) * kRangeL1 - 1), "value" + std::to_string(i)));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
MoveFilesToLevel(1); MoveFilesToLevel(1);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
ASSERT_OK(Put(Key(i * 30), "value" + ToString(i))); ASSERT_OK(Put(Key(i * 30), "value" + std::to_string(i)));
ASSERT_OK(Put(Key(i * 30 + 50), "value" + ToString(i))); ASSERT_OK(Put(Key(i * 30 + 50), "value" + std::to_string(i)));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }

View File

@ -999,7 +999,7 @@ TEST_F(DBSSTTest, DeleteSchedulerMultipleDBPaths) {
// Create 4 files in L0 // Create 4 files in L0
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
ASSERT_OK(Put("Key" + ToString(i), DummyString(1024, 'A'), wo)); ASSERT_OK(Put("Key" + std::to_string(i), DummyString(1024, 'A'), wo));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
// We created 4 sst files in L0 // We created 4 sst files in L0
@ -1015,7 +1015,7 @@ TEST_F(DBSSTTest, DeleteSchedulerMultipleDBPaths) {
// Create 4 files in L0 // Create 4 files in L0
for (int i = 4; i < 8; i++) { for (int i = 4; i < 8; i++) {
ASSERT_OK(Put("Key" + ToString(i), DummyString(1024, 'B'), wo)); ASSERT_OK(Put("Key" + std::to_string(i), DummyString(1024, 'B'), wo));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
ASSERT_EQ("4,1", FilesPerLevel(0)); ASSERT_EQ("4,1", FilesPerLevel(0));
@ -1061,7 +1061,7 @@ TEST_F(DBSSTTest, DestroyDBWithRateLimitedDelete) {
// Create 4 files in L0 // Create 4 files in L0
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
ASSERT_OK(Put("Key" + ToString(i), DummyString(1024, 'A'))); ASSERT_OK(Put("Key" + std::to_string(i), DummyString(1024, 'A')));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
// We created 4 sst files in L0 // We created 4 sst files in L0
@ -1530,7 +1530,7 @@ TEST_F(DBSSTTest, GetTotalSstFilesSize) {
// Generate 5 files in L0 // Generate 5 files in L0
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
std::string val = "val_file_" + ToString(i); std::string val = "val_file_" + std::to_string(i);
ASSERT_OK(Put(Key(j), val)); ASSERT_OK(Put(Key(j), val));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());

View File

@ -84,7 +84,8 @@ TEST_F(DBTablePropertiesTest, GetPropertiesOfAllTablesTest) {
} }
// Build file // Build file
for (int i = 0; i < 10 + table; ++i) { for (int i = 0; i < 10 + table; ++i) {
ASSERT_OK(db_->Put(WriteOptions(), ToString(table * 100 + i), "val")); ASSERT_OK(
db_->Put(WriteOptions(), std::to_string(table * 100 + i), "val"));
} }
ASSERT_OK(db_->Flush(FlushOptions())); ASSERT_OK(db_->Flush(FlushOptions()));
} }
@ -113,7 +114,7 @@ TEST_F(DBTablePropertiesTest, GetPropertiesOfAllTablesTest) {
// fetch key from 1st and 2nd table, which will internally place that table to // fetch key from 1st and 2nd table, which will internally place that table to
// the table cache. // the table cache.
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
Get(ToString(i * 100 + 0)); Get(std::to_string(i * 100 + 0));
} }
VerifyTableProperties(db_, 10 + 11 + 12 + 13); VerifyTableProperties(db_, 10 + 11 + 12 + 13);
@ -122,7 +123,7 @@ TEST_F(DBTablePropertiesTest, GetPropertiesOfAllTablesTest) {
Reopen(options); Reopen(options);
// fetch key from all tables, which will place them in table cache. // fetch key from all tables, which will place them in table cache.
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
Get(ToString(i * 100 + 0)); Get(std::to_string(i * 100 + 0));
} }
VerifyTableProperties(db_, 10 + 11 + 12 + 13); VerifyTableProperties(db_, 10 + 11 + 12 + 13);
@ -156,7 +157,7 @@ TEST_F(DBTablePropertiesTest, GetPropertiesOfAllTablesTest) {
} else { } else {
bool found_corruption = false; bool found_corruption = false;
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
std::string result = Get(ToString(i * 100 + 0)); std::string result = Get(std::to_string(i * 100 + 0));
if (result.find_first_of("Corruption: block checksum mismatch") != if (result.find_first_of("Corruption: block checksum mismatch") !=
std::string::npos) { std::string::npos) {
found_corruption = true; found_corruption = true;
@ -187,7 +188,7 @@ TEST_F(DBTablePropertiesTest, InvalidIgnored) {
// Build file // Build file
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
ASSERT_OK(db_->Put(WriteOptions(), ToString(i), "val")); ASSERT_OK(db_->Put(WriteOptions(), std::to_string(i), "val"));
} }
ASSERT_OK(db_->Flush(FlushOptions())); ASSERT_OK(db_->Flush(FlushOptions()));

View File

@ -2734,7 +2734,7 @@ TEST_P(MultiThreadedDBTest, MultiThreaded) {
Options options = CurrentOptions(options_override); Options options = CurrentOptions(options_override);
std::vector<std::string> cfs; std::vector<std::string> cfs;
for (int i = 1; i < kColumnFamilies; ++i) { for (int i = 1; i < kColumnFamilies; ++i) {
cfs.push_back(ToString(i)); cfs.push_back(std::to_string(i));
} }
Reopen(options); Reopen(options);
CreateAndReopenWithCF(cfs, options); CreateAndReopenWithCF(cfs, options);
@ -2786,7 +2786,7 @@ static void GCThreadBody(void* arg) {
WriteOptions wo; WriteOptions wo;
for (int i = 0; i < kGCNumKeys; ++i) { for (int i = 0; i < kGCNumKeys; ++i) {
std::string kv(ToString(i + id * kGCNumKeys)); std::string kv(std::to_string(i + id * kGCNumKeys));
ASSERT_OK(db->Put(wo, kv, kv)); ASSERT_OK(db->Put(wo, kv, kv));
} }
t->done = true; t->done = true;
@ -2822,7 +2822,7 @@ TEST_F(DBTest, GroupCommitTest) {
std::vector<std::string> expected_db; std::vector<std::string> expected_db;
for (int i = 0; i < kGCNumThreads * kGCNumKeys; ++i) { for (int i = 0; i < kGCNumThreads * kGCNumKeys; ++i) {
expected_db.push_back(ToString(i)); expected_db.push_back(std::to_string(i));
} }
std::sort(expected_db.begin(), expected_db.end()); std::sort(expected_db.begin(), expected_db.end());
@ -3591,7 +3591,7 @@ TEST_P(DBTestWithParam, FIFOCompactionTest) {
Random rnd(301); Random rnd(301);
for (int i = 0; i < 6; ++i) { for (int i = 0; i < 6; ++i) {
for (int j = 0; j < 110; ++j) { for (int j = 0; j < 110; ++j) {
ASSERT_OK(Put(ToString(i * 100 + j), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 100 + j), rnd.RandomString(980)));
} }
// flush should happen here // flush should happen here
ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable()); ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
@ -3607,7 +3607,7 @@ TEST_P(DBTestWithParam, FIFOCompactionTest) {
ASSERT_EQ(NumTableFilesAtLevel(0), 5); ASSERT_EQ(NumTableFilesAtLevel(0), 5);
for (int i = 0; i < 50; ++i) { for (int i = 0; i < 50; ++i) {
// these keys should be deleted in previous compaction // these keys should be deleted in previous compaction
ASSERT_EQ("NOT_FOUND", Get(ToString(i))); ASSERT_EQ("NOT_FOUND", Get(std::to_string(i)));
} }
} }
} }
@ -3629,7 +3629,7 @@ TEST_F(DBTest, FIFOCompactionTestWithCompaction) {
for (int i = 0; i < 60; i++) { for (int i = 0; i < 60; i++) {
// Generate and flush a file about 20KB. // Generate and flush a file about 20KB.
for (int j = 0; j < 20; j++) { for (int j = 0; j < 20; j++) {
ASSERT_OK(Put(ToString(i * 20 + j), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 20 + j), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -3640,7 +3640,7 @@ TEST_F(DBTest, FIFOCompactionTestWithCompaction) {
for (int i = 0; i < 60; i++) { for (int i = 0; i < 60; i++) {
// Generate and flush a file about 20KB. // Generate and flush a file about 20KB.
for (int j = 0; j < 20; j++) { for (int j = 0; j < 20; j++) {
ASSERT_OK(Put(ToString(i * 20 + j + 2000), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 20 + j + 2000), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -3670,27 +3670,27 @@ TEST_F(DBTest, FIFOCompactionStyleWithCompactionAndDelete) {
Random rnd(301); Random rnd(301);
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
// Each file contains a different key which will be dropped later. // Each file contains a different key which will be dropped later.
ASSERT_OK(Put("a" + ToString(i), rnd.RandomString(500))); ASSERT_OK(Put("a" + std::to_string(i), rnd.RandomString(500)));
ASSERT_OK(Put("key" + ToString(i), "")); ASSERT_OK(Put("key" + std::to_string(i), ""));
ASSERT_OK(Put("z" + ToString(i), rnd.RandomString(500))); ASSERT_OK(Put("z" + std::to_string(i), rnd.RandomString(500)));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
} }
ASSERT_EQ(NumTableFilesAtLevel(0), 1); ASSERT_EQ(NumTableFilesAtLevel(0), 1);
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
ASSERT_EQ("", Get("key" + ToString(i))); ASSERT_EQ("", Get("key" + std::to_string(i)));
} }
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
// Each file contains a different key which will be dropped later. // Each file contains a different key which will be dropped later.
ASSERT_OK(Put("a" + ToString(i), rnd.RandomString(500))); ASSERT_OK(Put("a" + std::to_string(i), rnd.RandomString(500)));
ASSERT_OK(Delete("key" + ToString(i))); ASSERT_OK(Delete("key" + std::to_string(i)));
ASSERT_OK(Put("z" + ToString(i), rnd.RandomString(500))); ASSERT_OK(Put("z" + std::to_string(i), rnd.RandomString(500)));
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
} }
ASSERT_EQ(NumTableFilesAtLevel(0), 2); ASSERT_EQ(NumTableFilesAtLevel(0), 2);
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
ASSERT_EQ("NOT_FOUND", Get("key" + ToString(i))); ASSERT_EQ("NOT_FOUND", Get("key" + std::to_string(i)));
} }
} }
@ -3759,7 +3759,7 @@ TEST_F(DBTest, FIFOCompactionWithTTLTest) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
// Generate and flush a file about 10KB. // Generate and flush a file about 10KB.
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
ASSERT_OK(Put(ToString(i * 20 + j), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 20 + j), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -3791,7 +3791,7 @@ TEST_F(DBTest, FIFOCompactionWithTTLTest) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
// Generate and flush a file about 10KB. // Generate and flush a file about 10KB.
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
ASSERT_OK(Put(ToString(i * 20 + j), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 20 + j), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -3807,7 +3807,7 @@ TEST_F(DBTest, FIFOCompactionWithTTLTest) {
// Create 1 more file to trigger TTL compaction. The old files are dropped. // Create 1 more file to trigger TTL compaction. The old files are dropped.
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
ASSERT_OK(Put(ToString(i * 20 + j), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 20 + j), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
} }
@ -3833,7 +3833,7 @@ TEST_F(DBTest, FIFOCompactionWithTTLTest) {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
// Generate and flush a file about 10KB. // Generate and flush a file about 10KB.
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
ASSERT_OK(Put(ToString(i * 20 + j), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 20 + j), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -3848,7 +3848,7 @@ TEST_F(DBTest, FIFOCompactionWithTTLTest) {
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
for (int j = 0; j < 140; j++) { for (int j = 0; j < 140; j++) {
ASSERT_OK(Put(ToString(i * 20 + j), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 20 + j), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -3871,7 +3871,7 @@ TEST_F(DBTest, FIFOCompactionWithTTLTest) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
// Generate and flush a file about 10KB. // Generate and flush a file about 10KB.
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
ASSERT_OK(Put(ToString(i * 20 + j), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 20 + j), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -3890,7 +3890,7 @@ TEST_F(DBTest, FIFOCompactionWithTTLTest) {
// Create 10 more files. The old 5 files are dropped as their ttl expired. // Create 10 more files. The old 5 files are dropped as their ttl expired.
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
ASSERT_OK(Put(ToString(i * 20 + j), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 20 + j), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -3915,7 +3915,7 @@ TEST_F(DBTest, FIFOCompactionWithTTLTest) {
for (int i = 0; i < 60; i++) { for (int i = 0; i < 60; i++) {
// Generate and flush a file about 20KB. // Generate and flush a file about 20KB.
for (int j = 0; j < 20; j++) { for (int j = 0; j < 20; j++) {
ASSERT_OK(Put(ToString(i * 20 + j), rnd.RandomString(980))); ASSERT_OK(Put(std::to_string(i * 20 + j), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -3926,7 +3926,8 @@ TEST_F(DBTest, FIFOCompactionWithTTLTest) {
for (int i = 0; i < 60; i++) { for (int i = 0; i < 60; i++) {
// Generate and flush a file about 20KB. // Generate and flush a file about 20KB.
for (int j = 0; j < 20; j++) { for (int j = 0; j < 20; j++) {
ASSERT_OK(Put(ToString(i * 20 + j + 2000), rnd.RandomString(980))); ASSERT_OK(
Put(std::to_string(i * 20 + j + 2000), rnd.RandomString(980)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());
@ -4207,7 +4208,7 @@ TEST_F(DBTest, ConcurrentFlushWAL) {
std::vector<port::Thread> threads; std::vector<port::Thread> threads;
threads.emplace_back([&] { threads.emplace_back([&] {
for (size_t i = 0; i < cnt; i++) { for (size_t i = 0; i < cnt; i++) {
auto istr = ToString(i); auto istr = std::to_string(i);
ASSERT_OK(db_->Put(wopt, db_->DefaultColumnFamily(), "a" + istr, ASSERT_OK(db_->Put(wopt, db_->DefaultColumnFamily(), "a" + istr,
"b" + istr)); "b" + istr));
} }
@ -4215,7 +4216,7 @@ TEST_F(DBTest, ConcurrentFlushWAL) {
if (two_write_queues) { if (two_write_queues) {
threads.emplace_back([&] { threads.emplace_back([&] {
for (size_t i = cnt; i < 2 * cnt; i++) { for (size_t i = cnt; i < 2 * cnt; i++) {
auto istr = ToString(i); auto istr = std::to_string(i);
WriteBatch batch; WriteBatch batch;
ASSERT_OK(batch.Put("a" + istr, "b" + istr)); ASSERT_OK(batch.Put("a" + istr, "b" + istr));
ASSERT_OK( ASSERT_OK(
@ -4236,7 +4237,7 @@ TEST_F(DBTest, ConcurrentFlushWAL) {
Reopen(options); Reopen(options);
for (size_t i = 0; i < cnt; i++) { for (size_t i = 0; i < cnt; i++) {
PinnableSlice pval; PinnableSlice pval;
auto istr = ToString(i); auto istr = std::to_string(i);
ASSERT_OK( ASSERT_OK(
db_->Get(ropt, db_->DefaultColumnFamily(), "a" + istr, &pval)); db_->Get(ropt, db_->DefaultColumnFamily(), "a" + istr, &pval));
ASSERT_TRUE(pval == ("b" + istr)); ASSERT_TRUE(pval == ("b" + istr));
@ -4259,7 +4260,7 @@ TEST_F(DBTest, ManualFlushWalAndWriteRace) {
port::Thread writeThread([&]() { port::Thread writeThread([&]() {
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
auto istr = ToString(i); auto istr = std::to_string(i);
ASSERT_OK(dbfull()->Put(wopts, "key_" + istr, "value_" + istr)); ASSERT_OK(dbfull()->Put(wopts, "key_" + istr, "value_" + istr));
} }
}); });
@ -4607,7 +4608,7 @@ TEST_P(DBTestWithParam, ThreadStatusSingleCompaction) {
// The Put Phase. // The Put Phase.
for (int file = 0; file < kNumL0Files; ++file) { for (int file = 0; file < kNumL0Files; ++file) {
for (int key = 0; key < kEntriesPerBuffer; ++key) { for (int key = 0; key < kEntriesPerBuffer; ++key) {
ASSERT_OK(Put(ToString(key + file * kEntriesPerBuffer), ASSERT_OK(Put(std::to_string(key + file * kEntriesPerBuffer),
rnd.RandomString(kTestValueSize))); rnd.RandomString(kTestValueSize)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
@ -4758,7 +4759,7 @@ TEST_P(DBTestWithParam, PreShutdownMultipleCompaction) {
int operation_count[ThreadStatus::NUM_OP_TYPES] = {0}; int operation_count[ThreadStatus::NUM_OP_TYPES] = {0};
for (int file = 0; file < 16 * kNumL0Files; ++file) { for (int file = 0; file < 16 * kNumL0Files; ++file) {
for (int k = 0; k < kEntriesPerBuffer; ++k) { for (int k = 0; k < kEntriesPerBuffer; ++k) {
ASSERT_OK(Put(ToString(key++), rnd.RandomString(kTestValueSize))); ASSERT_OK(Put(std::to_string(key++), rnd.RandomString(kTestValueSize)));
} }
ASSERT_OK(env_->GetThreadList(&thread_list)); ASSERT_OK(env_->GetThreadList(&thread_list));
@ -4845,7 +4846,7 @@ TEST_P(DBTestWithParam, PreShutdownCompactionMiddle) {
int operation_count[ThreadStatus::NUM_OP_TYPES] = {0}; int operation_count[ThreadStatus::NUM_OP_TYPES] = {0};
for (int file = 0; file < 16 * kNumL0Files; ++file) { for (int file = 0; file < 16 * kNumL0Files; ++file) {
for (int k = 0; k < kEntriesPerBuffer; ++k) { for (int k = 0; k < kEntriesPerBuffer; ++k) {
ASSERT_OK(Put(ToString(key++), rnd.RandomString(kTestValueSize))); ASSERT_OK(Put(std::to_string(key++), rnd.RandomString(kTestValueSize)));
} }
ASSERT_OK(env_->GetThreadList(&thread_list)); ASSERT_OK(env_->GetThreadList(&thread_list));
@ -5156,8 +5157,9 @@ TEST_F(DBTest, DynamicCompactionOptions) {
// Writing to 64KB L0 files should trigger a compaction. Since these // Writing to 64KB L0 files should trigger a compaction. Since these
// 2 L0 files have the same key range, compaction merge them and should // 2 L0 files have the same key range, compaction merge them and should
// result in 2 32KB L1 files. // result in 2 32KB L1 files.
ASSERT_OK(dbfull()->SetOptions({{"level0_file_num_compaction_trigger", "2"}, ASSERT_OK(
{"target_file_size_base", ToString(k32KB)}})); dbfull()->SetOptions({{"level0_file_num_compaction_trigger", "2"},
{"target_file_size_base", std::to_string(k32KB)}}));
gen_l0_kb(0, 64, 1); gen_l0_kb(0, 64, 1);
ASSERT_EQ("1,1", FilesPerLevel()); ASSERT_EQ("1,1", FilesPerLevel());
@ -5176,8 +5178,8 @@ TEST_F(DBTest, DynamicCompactionOptions) {
// Increase level base size to 256KB and write enough data that will // Increase level base size to 256KB and write enough data that will
// fill L1 and L2. L1 size should be around 256KB while L2 size should be // fill L1 and L2. L1 size should be around 256KB while L2 size should be
// around 256KB x 4. // around 256KB x 4.
ASSERT_OK( ASSERT_OK(dbfull()->SetOptions(
dbfull()->SetOptions({{"max_bytes_for_level_base", ToString(k1MB)}})); {{"max_bytes_for_level_base", std::to_string(k1MB)}}));
// writing 96 x 64KB => 6 * 1024KB // writing 96 x 64KB => 6 * 1024KB
// (L1 + L2) = (1 + 4) * 1024KB // (L1 + L2) = (1 + 4) * 1024KB
@ -5196,9 +5198,9 @@ TEST_F(DBTest, DynamicCompactionOptions) {
// max_bytes_for_level_base. Now, reduce both mulitplier and level base, // max_bytes_for_level_base. Now, reduce both mulitplier and level base,
// After filling enough data that can fit in L1 - L3, we should see L1 size // After filling enough data that can fit in L1 - L3, we should see L1 size
// reduces to 128KB from 256KB which was asserted previously. Same for L2. // reduces to 128KB from 256KB which was asserted previously. Same for L2.
ASSERT_OK( ASSERT_OK(dbfull()->SetOptions(
dbfull()->SetOptions({{"max_bytes_for_level_multiplier", "2"}, {{"max_bytes_for_level_multiplier", "2"},
{"max_bytes_for_level_base", ToString(k128KB)}})); {"max_bytes_for_level_base", std::to_string(k128KB)}}));
// writing 20 x 64KB = 10 x 128KB // writing 20 x 64KB = 10 x 128KB
// (L1 + L2 + L3) = (1 + 2 + 4) * 128KB // (L1 + L2 + L3) = (1 + 2 + 4) * 128KB
@ -5854,7 +5856,7 @@ TEST_P(DBTestWithParam, FilterCompactionTimeTest) {
// put some data // put some data
for (int table = 0; table < 4; ++table) { for (int table = 0; table < 4; ++table) {
for (int i = 0; i < 10 + table; ++i) { for (int i = 0; i < 10 + table; ++i) {
ASSERT_OK(Put(ToString(table * 100 + i), "val")); ASSERT_OK(Put(std::to_string(table * 100 + i), "val"));
++n; ++n;
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
@ -6238,7 +6240,7 @@ TEST_F(DBTest, LargeBatchWithColumnFamilies) {
(write_size / 1024 / 1024), pass); (write_size / 1024 / 1024), pass);
for (;;) { for (;;) {
std::string data(3000, j++ % 127 + 20); std::string data(3000, j++ % 127 + 20);
data += ToString(j); data += std::to_string(j);
ASSERT_OK(batch.Put(handles_[0], Slice(data), Slice(data))); ASSERT_OK(batch.Put(handles_[0], Slice(data), Slice(data)));
if (batch.GetDataSize() > write_size) { if (batch.GetDataSize() > write_size) {
break; break;

View File

@ -38,9 +38,9 @@ class DBTest2 : public DBTestBase {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
uint64_t GetSstSizeHelper(Temperature temperature) { uint64_t GetSstSizeHelper(Temperature temperature) {
std::string prop; std::string prop;
EXPECT_TRUE( EXPECT_TRUE(dbfull()->GetProperty(
dbfull()->GetProperty(DB::Properties::kLiveSstFilesSizeAtTemperature + DB::Properties::kLiveSstFilesSizeAtTemperature +
ToString(static_cast<uint8_t>(temperature)), std::to_string(static_cast<uint8_t>(temperature)),
&prop)); &prop));
return static_cast<uint64_t>(std::atoi(prop.c_str())); return static_cast<uint64_t>(std::atoi(prop.c_str()));
} }
@ -1694,8 +1694,8 @@ class CompactionCompressionListener : public EventListener {
int bottommost_level = 0; int bottommost_level = 0;
for (int level = 0; level < db->NumberLevels(); level++) { for (int level = 0; level < db->NumberLevels(); level++) {
std::string files_at_level; std::string files_at_level;
ASSERT_TRUE(db->GetProperty( ASSERT_TRUE(
"rocksdb.num-files-at-level" + ROCKSDB_NAMESPACE::ToString(level), db->GetProperty("rocksdb.num-files-at-level" + std::to_string(level),
&files_at_level)); &files_at_level));
if (files_at_level != "0") { if (files_at_level != "0") {
bottommost_level = level; bottommost_level = level;
@ -2492,14 +2492,14 @@ TEST_F(DBTest2, TestPerfContextIterCpuTime) {
const size_t kNumEntries = 10; const size_t kNumEntries = 10;
for (size_t i = 0; i < kNumEntries; ++i) { for (size_t i = 0; i < kNumEntries; ++i) {
ASSERT_OK(Put("k" + ToString(i), "v" + ToString(i))); ASSERT_OK(Put("k" + std::to_string(i), "v" + std::to_string(i)));
} }
ASSERT_OK(Flush()); ASSERT_OK(Flush());
for (size_t i = 0; i < kNumEntries; ++i) { for (size_t i = 0; i < kNumEntries; ++i) {
ASSERT_EQ("v" + ToString(i), Get("k" + ToString(i))); ASSERT_EQ("v" + std::to_string(i), Get("k" + std::to_string(i)));
} }
std::string last_key = "k" + ToString(kNumEntries - 1); std::string last_key = "k" + std::to_string(kNumEntries - 1);
std::string last_value = "v" + ToString(kNumEntries - 1); std::string last_value = "v" + std::to_string(kNumEntries - 1);
env_->now_cpu_count_.store(0); env_->now_cpu_count_.store(0);
env_->SetMockSleep(); env_->SetMockSleep();
@ -5553,7 +5553,7 @@ TEST_F(DBTest2, MultiDBParallelOpenTest) {
Options options = CurrentOptions(); Options options = CurrentOptions();
std::vector<std::string> dbnames; std::vector<std::string> dbnames;
for (int i = 0; i < kNumDbs; ++i) { for (int i = 0; i < kNumDbs; ++i) {
dbnames.emplace_back(test::PerThreadDBPath(env_, "db" + ToString(i))); dbnames.emplace_back(test::PerThreadDBPath(env_, "db" + std::to_string(i)));
ASSERT_OK(DestroyDB(dbnames.back(), options)); ASSERT_OK(DestroyDB(dbnames.back(), options));
} }

View File

@ -1086,11 +1086,11 @@ int DBTestBase::NumTableFilesAtLevel(int level, int cf) {
std::string property; std::string property;
if (cf == 0) { if (cf == 0) {
// default cfd // default cfd
EXPECT_TRUE(db_->GetProperty("rocksdb.num-files-at-level" + ToString(level), EXPECT_TRUE(db_->GetProperty(
&property)); "rocksdb.num-files-at-level" + std::to_string(level), &property));
} else { } else {
EXPECT_TRUE(db_->GetProperty(handles_[cf], EXPECT_TRUE(db_->GetProperty(
"rocksdb.num-files-at-level" + ToString(level), handles_[cf], "rocksdb.num-files-at-level" + std::to_string(level),
&property)); &property));
} }
return atoi(property.c_str()); return atoi(property.c_str());
@ -1101,10 +1101,12 @@ double DBTestBase::CompressionRatioAtLevel(int level, int cf) {
if (cf == 0) { if (cf == 0) {
// default cfd // default cfd
EXPECT_TRUE(db_->GetProperty( EXPECT_TRUE(db_->GetProperty(
"rocksdb.compression-ratio-at-level" + ToString(level), &property)); "rocksdb.compression-ratio-at-level" + std::to_string(level),
&property));
} else { } else {
EXPECT_TRUE(db_->GetProperty( EXPECT_TRUE(db_->GetProperty(
handles_[cf], "rocksdb.compression-ratio-at-level" + ToString(level), handles_[cf],
"rocksdb.compression-ratio-at-level" + std::to_string(level),
&property)); &property));
} }
return std::stod(property); return std::stod(property);

View File

@ -549,7 +549,7 @@ TEST_P(DBTestUniversalCompaction, CompactFilesOnUniversalCompaction) {
ASSERT_EQ(options.compaction_style, kCompactionStyleUniversal); ASSERT_EQ(options.compaction_style, kCompactionStyleUniversal);
Random rnd(301); Random rnd(301);
for (int key = 1024 * kEntriesPerBuffer; key >= 0; --key) { for (int key = 1024 * kEntriesPerBuffer; key >= 0; --key) {
ASSERT_OK(Put(1, ToString(key), rnd.RandomString(kTestValueSize))); ASSERT_OK(Put(1, std::to_string(key), rnd.RandomString(kTestValueSize)));
} }
ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable(handles_[1])); ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable(handles_[1]));
ASSERT_OK(dbfull()->TEST_WaitForCompact()); ASSERT_OK(dbfull()->TEST_WaitForCompact());

View File

@ -1288,7 +1288,7 @@ class RecoveryTestHelper {
WriteBatch batch; WriteBatch batch;
for (int i = 0; i < kKeysPerWALFile; i++) { for (int i = 0; i < kKeysPerWALFile; i++) {
std::string key = "key" + ToString((*count)++); std::string key = "key" + std::to_string((*count)++);
std::string value = test->DummyString(kValueSize); std::string value = test->DummyString(kValueSize);
ASSERT_NE(current_log_writer.get(), nullptr); ASSERT_NE(current_log_writer.get(), nullptr);
uint64_t seq = versions->LastSequence() + 1; uint64_t seq = versions->LastSequence() + 1;
@ -1319,7 +1319,7 @@ class RecoveryTestHelper {
static size_t GetData(DBWALTestBase* test) { static size_t GetData(DBWALTestBase* test) {
size_t count = 0; size_t count = 0;
for (size_t i = 0; i < kWALFilesCount * kKeysPerWALFile; i++) { for (size_t i = 0; i < kWALFilesCount * kKeysPerWALFile; i++) {
if (test->Get("key" + ToString(i)) != "NOT_FOUND") { if (test->Get("key" + std::to_string(i)) != "NOT_FOUND") {
++count; ++count;
} }
} }
@ -1616,7 +1616,7 @@ TEST_P(DBWALTestWithParams, kPointInTimeRecovery) {
if (!trunc || corrupt_offset != 0) { if (!trunc || corrupt_offset != 0) {
bool expect_data = true; bool expect_data = true;
for (size_t k = 0; k < maxkeys; ++k) { for (size_t k = 0; k < maxkeys; ++k) {
bool found = Get("key" + ToString(k)) != "NOT_FOUND"; bool found = Get("key" + std::to_string(k)) != "NOT_FOUND";
if (expect_data && !found) { if (expect_data && !found) {
expect_data = false; expect_data = false;
} }
@ -1752,7 +1752,7 @@ TEST_F(DBWALTest, RecoverWithoutFlush) {
size_t count = RecoveryTestHelper::FillData(this, &options); size_t count = RecoveryTestHelper::FillData(this, &options);
auto validateData = [this, count]() { auto validateData = [this, count]() {
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
ASSERT_NE(Get("key" + ToString(i)), "NOT_FOUND"); ASSERT_NE(Get("key" + std::to_string(i)), "NOT_FOUND");
} }
}; };
Reopen(options); Reopen(options);
@ -1891,7 +1891,7 @@ TEST_P(DBWALTestWithParamsVaryingRecoveryMode,
ASSERT_OK(TryReopen(options)); ASSERT_OK(TryReopen(options));
// Append some more data. // Append some more data.
for (int k = 0; k < kAppendKeys; k++) { for (int k = 0; k < kAppendKeys; k++) {
std::string key = "extra_key" + ToString(k); std::string key = "extra_key" + std::to_string(k);
std::string value = DummyString(RecoveryTestHelper::kValueSize); std::string value = DummyString(RecoveryTestHelper::kValueSize);
ASSERT_OK(Put(key, value)); ASSERT_OK(Put(key, value));
} }
@ -1925,7 +1925,7 @@ TEST_F(DBWALTest, RestoreTotalLogSizeAfterRecoverWithoutFlush) {
std::string value_300k(300 * kKB, 'v'); std::string value_300k(300 * kKB, 'v');
ASSERT_OK(Put(0, "foo", "v1")); ASSERT_OK(Put(0, "foo", "v1"));
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
ASSERT_OK(Put(1, "key" + ToString(i), value_100k)); ASSERT_OK(Put(1, "key" + std::to_string(i), value_100k));
} }
// Get log files before reopen. // Get log files before reopen.
VectorLogPtr log_files_before; VectorLogPtr log_files_before;

View File

@ -1492,8 +1492,8 @@ TEST_F(DBBasicTestWithTimestamp, MultiGetRangeFiltering) {
// random data // random data
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
auto key = ToString(i * 10); auto key = std::to_string(i * 10);
auto value = ToString(i * 10); auto value = std::to_string(i * 10);
Slice key_slice = key; Slice key_slice = key;
Slice value_slice = value; Slice value_slice = value;
ASSERT_OK(db_->Put(write_opts, key_slice, ts, value_slice)); ASSERT_OK(db_->Put(write_opts, key_slice, ts, value_slice));
@ -1824,8 +1824,8 @@ class DataVisibilityTest : public DBBasicTestWithTimestampBase {
DataVisibilityTest() : DBBasicTestWithTimestampBase("data_visibility_test") { DataVisibilityTest() : DBBasicTestWithTimestampBase("data_visibility_test") {
// Initialize test data // Initialize test data
for (int i = 0; i < kTestDataSize; i++) { for (int i = 0; i < kTestDataSize; i++) {
test_data_[i].key = "key" + ToString(i); test_data_[i].key = "key" + std::to_string(i);
test_data_[i].value = "value" + ToString(i); test_data_[i].value = "value" + std::to_string(i);
test_data_[i].timestamp = Timestamp(i, 0); test_data_[i].timestamp = Timestamp(i, 0);
test_data_[i].ts = i; test_data_[i].ts = i;
test_data_[i].seq_num = kMaxSequenceNumber; test_data_[i].seq_num = kMaxSequenceNumber;

View File

@ -289,7 +289,7 @@ TEST_P(DBWriteTest, IOErrorOnWALWritePropagateToWriteThreadFollower) {
threads.push_back(port::Thread( threads.push_back(port::Thread(
[&](int index) { [&](int index) {
// All threads should fail. // All threads should fail.
auto res = Put("key" + ToString(index), "value"); auto res = Put("key" + std::to_string(index), "value");
if (options.manual_wal_flush) { if (options.manual_wal_flush) {
ASSERT_TRUE(res.ok()); ASSERT_TRUE(res.ok());
// we should see fs error when we do the flush // we should see fs error when we do the flush
@ -322,13 +322,13 @@ TEST_P(DBWriteTest, ManualWalFlushInEffect) {
Options options = GetOptions(); Options options = GetOptions();
Reopen(options); Reopen(options);
// try the 1st WAL created during open // try the 1st WAL created during open
ASSERT_TRUE(Put("key" + ToString(0), "value").ok()); ASSERT_TRUE(Put("key" + std::to_string(0), "value").ok());
ASSERT_TRUE(options.manual_wal_flush != dbfull()->TEST_WALBufferIsEmpty()); ASSERT_TRUE(options.manual_wal_flush != dbfull()->TEST_WALBufferIsEmpty());
ASSERT_TRUE(dbfull()->FlushWAL(false).ok()); ASSERT_TRUE(dbfull()->FlushWAL(false).ok());
ASSERT_TRUE(dbfull()->TEST_WALBufferIsEmpty()); ASSERT_TRUE(dbfull()->TEST_WALBufferIsEmpty());
// try the 2nd wal created during SwitchWAL // try the 2nd wal created during SwitchWAL
ASSERT_OK(dbfull()->TEST_SwitchWAL()); ASSERT_OK(dbfull()->TEST_SwitchWAL());
ASSERT_TRUE(Put("key" + ToString(0), "value").ok()); ASSERT_TRUE(Put("key" + std::to_string(0), "value").ok());
ASSERT_TRUE(options.manual_wal_flush != dbfull()->TEST_WALBufferIsEmpty()); ASSERT_TRUE(options.manual_wal_flush != dbfull()->TEST_WALBufferIsEmpty());
ASSERT_TRUE(dbfull()->FlushWAL(false).ok()); ASSERT_TRUE(dbfull()->FlushWAL(false).ok());
ASSERT_TRUE(dbfull()->TEST_WALBufferIsEmpty()); ASSERT_TRUE(dbfull()->TEST_WALBufferIsEmpty());
@ -344,7 +344,7 @@ TEST_P(DBWriteTest, IOErrorOnWALWriteTriggersReadOnlyMode) {
// Forcibly fail WAL write for the first Put only. Subsequent Puts should // Forcibly fail WAL write for the first Put only. Subsequent Puts should
// fail due to read-only mode // fail due to read-only mode
mock_env->SetFilesystemActive(i != 0); mock_env->SetFilesystemActive(i != 0);
auto res = Put("key" + ToString(i), "value"); auto res = Put("key" + std::to_string(i), "value");
// TSAN reports a false alarm for lock-order-inversion but Open and // TSAN reports a false alarm for lock-order-inversion but Open and
// FlushWAL are not run concurrently. Disabling this until TSAN is // FlushWAL are not run concurrently. Disabling this until TSAN is
// fixed. // fixed.
@ -398,14 +398,14 @@ TEST_P(DBWriteTest, LockWalInEffect) {
Options options = GetOptions(); Options options = GetOptions();
Reopen(options); Reopen(options);
// try the 1st WAL created during open // try the 1st WAL created during open
ASSERT_OK(Put("key" + ToString(0), "value")); ASSERT_OK(Put("key" + std::to_string(0), "value"));
ASSERT_TRUE(options.manual_wal_flush != dbfull()->TEST_WALBufferIsEmpty()); ASSERT_TRUE(options.manual_wal_flush != dbfull()->TEST_WALBufferIsEmpty());
ASSERT_OK(dbfull()->LockWAL()); ASSERT_OK(dbfull()->LockWAL());
ASSERT_TRUE(dbfull()->TEST_WALBufferIsEmpty(false)); ASSERT_TRUE(dbfull()->TEST_WALBufferIsEmpty(false));
ASSERT_OK(dbfull()->UnlockWAL()); ASSERT_OK(dbfull()->UnlockWAL());
// try the 2nd wal created during SwitchWAL // try the 2nd wal created during SwitchWAL
ASSERT_OK(dbfull()->TEST_SwitchWAL()); ASSERT_OK(dbfull()->TEST_SwitchWAL());
ASSERT_OK(Put("key" + ToString(0), "value")); ASSERT_OK(Put("key" + std::to_string(0), "value"));
ASSERT_TRUE(options.manual_wal_flush != dbfull()->TEST_WALBufferIsEmpty()); ASSERT_TRUE(options.manual_wal_flush != dbfull()->TEST_WALBufferIsEmpty());
ASSERT_OK(dbfull()->LockWAL()); ASSERT_OK(dbfull()->LockWAL());
ASSERT_TRUE(dbfull()->TEST_WALBufferIsEmpty(false)); ASSERT_TRUE(dbfull()->TEST_WALBufferIsEmpty(false));

View File

@ -56,7 +56,7 @@ class DeleteFileTest : public DBTestBase {
options.sync = false; options.sync = false;
ReadOptions roptions; ReadOptions roptions;
for (int i = startkey; i < (numkeys + startkey) ; i++) { for (int i = startkey; i < (numkeys + startkey) ; i++) {
std::string temp = ToString(i); std::string temp = std::to_string(i);
Slice key(temp); Slice key(temp);
Slice value(temp); Slice value(temp);
ASSERT_OK(db_->Put(options, key, value)); ASSERT_OK(db_->Put(options, key, value));

View File

@ -1583,11 +1583,11 @@ TEST_F(DBErrorHandlingFSTest, MultiDBCompactionError) {
std::string prop; std::string prop;
ASSERT_EQ(listener[i]->WaitForRecovery(5000000), true); ASSERT_EQ(listener[i]->WaitForRecovery(5000000), true);
ASSERT_OK(static_cast<DBImpl*>(db[i])->TEST_WaitForCompact(true)); ASSERT_OK(static_cast<DBImpl*>(db[i])->TEST_WaitForCompact(true));
EXPECT_TRUE( EXPECT_TRUE(db[i]->GetProperty(
db[i]->GetProperty("rocksdb.num-files-at-level" + ToString(0), &prop)); "rocksdb.num-files-at-level" + std::to_string(0), &prop));
EXPECT_EQ(atoi(prop.c_str()), 0); EXPECT_EQ(atoi(prop.c_str()), 0);
EXPECT_TRUE( EXPECT_TRUE(db[i]->GetProperty(
db[i]->GetProperty("rocksdb.num-files-at-level" + ToString(1), &prop)); "rocksdb.num-files-at-level" + std::to_string(1), &prop));
EXPECT_EQ(atoi(prop.c_str()), 1); EXPECT_EQ(atoi(prop.c_str()), 1);
} }
@ -1720,11 +1720,11 @@ TEST_F(DBErrorHandlingFSTest, MultiDBVariousErrors) {
if (i == 1) { if (i == 1) {
ASSERT_OK(static_cast<DBImpl*>(db[i])->TEST_WaitForCompact(true)); ASSERT_OK(static_cast<DBImpl*>(db[i])->TEST_WaitForCompact(true));
} }
EXPECT_TRUE( EXPECT_TRUE(db[i]->GetProperty(
db[i]->GetProperty("rocksdb.num-files-at-level" + ToString(0), &prop)); "rocksdb.num-files-at-level" + std::to_string(0), &prop));
EXPECT_EQ(atoi(prop.c_str()), 0); EXPECT_EQ(atoi(prop.c_str()), 0);
EXPECT_TRUE( EXPECT_TRUE(db[i]->GetProperty(
db[i]->GetProperty("rocksdb.num-files-at-level" + ToString(1), &prop)); "rocksdb.num-files-at-level" + std::to_string(1), &prop));
EXPECT_EQ(atoi(prop.c_str()), 1); EXPECT_EQ(atoi(prop.c_str()), 1);
} }

View File

@ -91,7 +91,7 @@ class ExternalSSTFileBasicTest
bool write_global_seqno, bool verify_checksums_before_ingest, bool write_global_seqno, bool verify_checksums_before_ingest,
std::map<std::string, std::string>* true_data) { std::map<std::string, std::string>* true_data) {
assert(value_types.size() == 1 || keys.size() == value_types.size()); assert(value_types.size() == 1 || keys.size() == value_types.size());
std::string file_path = sst_files_dir_ + ToString(file_id); std::string file_path = sst_files_dir_ + std::to_string(file_id);
SstFileWriter sst_file_writer(EnvOptions(), options); SstFileWriter sst_file_writer(EnvOptions(), options);
Status s = sst_file_writer.Open(file_path); Status s = sst_file_writer.Open(file_path);
@ -123,7 +123,7 @@ class ExternalSSTFileBasicTest
} }
for (size_t i = 0; i < keys.size(); i++) { for (size_t i = 0; i < keys.size(); i++) {
std::string key = Key(keys[i]); std::string key = Key(keys[i]);
std::string value = Key(keys[i]) + ToString(file_id); std::string value = Key(keys[i]) + std::to_string(file_id);
ValueType value_type = ValueType value_type =
(value_types.size() == 1 ? value_types[0] : value_types[i]); (value_types.size() == 1 ? value_types[0] : value_types[i]);
switch (value_type) { switch (value_type) {
@ -190,9 +190,9 @@ class ExternalSSTFileBasicTest
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
uint64_t GetSstSizeHelper(Temperature temperature) { uint64_t GetSstSizeHelper(Temperature temperature) {
std::string prop; std::string prop;
EXPECT_TRUE( EXPECT_TRUE(dbfull()->GetProperty(
dbfull()->GetProperty(DB::Properties::kLiveSstFilesSizeAtTemperature + DB::Properties::kLiveSstFilesSizeAtTemperature +
ToString(static_cast<uint8_t>(temperature)), std::to_string(static_cast<uint8_t>(temperature)),
&prop)); &prop));
return static_cast<uint64_t>(std::atoi(prop.c_str())); return static_cast<uint64_t>(std::atoi(prop.c_str()));
} }
@ -1184,7 +1184,7 @@ TEST_F(ExternalSSTFileBasicTest, SyncFailure) {
std::unique_ptr<SstFileWriter> sst_file_writer( std::unique_ptr<SstFileWriter> sst_file_writer(
new SstFileWriter(EnvOptions(), sst_file_writer_options)); new SstFileWriter(EnvOptions(), sst_file_writer_options));
std::string file_name = std::string file_name =
sst_files_dir_ + "sync_failure_test_" + ToString(i) + ".sst"; sst_files_dir_ + "sync_failure_test_" + std::to_string(i) + ".sst";
ASSERT_OK(sst_file_writer->Open(file_name)); ASSERT_OK(sst_file_writer->Open(file_name));
ASSERT_OK(sst_file_writer->Put("bar", "v2")); ASSERT_OK(sst_file_writer->Put("bar", "v2"));
ASSERT_OK(sst_file_writer->Finish()); ASSERT_OK(sst_file_writer->Finish());
@ -1514,13 +1514,13 @@ TEST_P(ExternalSSTFileBasicTest, IngestFileWithFirstByteTampered) {
EnvOptions env_options; EnvOptions env_options;
do { do {
Options options = CurrentOptions(); Options options = CurrentOptions();
std::string file_path = sst_files_dir_ + ToString(file_id++); std::string file_path = sst_files_dir_ + std::to_string(file_id++);
SstFileWriter sst_file_writer(env_options, options); SstFileWriter sst_file_writer(env_options, options);
Status s = sst_file_writer.Open(file_path); Status s = sst_file_writer.Open(file_path);
ASSERT_OK(s); ASSERT_OK(s);
for (int i = 0; i != 100; ++i) { for (int i = 0; i != 100; ++i) {
std::string key = Key(i); std::string key = Key(i);
std::string value = Key(i) + ToString(0); std::string value = Key(i) + std::to_string(0);
ASSERT_OK(sst_file_writer.Put(key, value)); ASSERT_OK(sst_file_writer.Put(key, value));
} }
ASSERT_OK(sst_file_writer.Finish()); ASSERT_OK(sst_file_writer.Finish());
@ -1585,14 +1585,14 @@ TEST_P(ExternalSSTFileBasicTest, IngestExternalFileWithCorruptedPropsBlock) {
int file_id = 0; int file_id = 0;
Random64 rand(time(nullptr)); Random64 rand(time(nullptr));
do { do {
std::string file_path = sst_files_dir_ + ToString(file_id++); std::string file_path = sst_files_dir_ + std::to_string(file_id++);
Options options = CurrentOptions(); Options options = CurrentOptions();
SstFileWriter sst_file_writer(EnvOptions(), options); SstFileWriter sst_file_writer(EnvOptions(), options);
Status s = sst_file_writer.Open(file_path); Status s = sst_file_writer.Open(file_path);
ASSERT_OK(s); ASSERT_OK(s);
for (int i = 0; i != 100; ++i) { for (int i = 0; i != 100; ++i) {
std::string key = Key(i); std::string key = Key(i);
std::string value = Key(i) + ToString(0); std::string value = Key(i) + std::to_string(0);
ASSERT_OK(sst_file_writer.Put(key, value)); ASSERT_OK(sst_file_writer.Put(key, value));
} }
ASSERT_OK(sst_file_writer.Finish()); ASSERT_OK(sst_file_writer.Finish());
@ -1799,7 +1799,7 @@ TEST_F(ExternalSSTFileBasicTest, IngestWithTemperature) {
TEST_F(ExternalSSTFileBasicTest, FailIfNotBottommostLevel) { TEST_F(ExternalSSTFileBasicTest, FailIfNotBottommostLevel) {
Options options = GetDefaultOptions(); Options options = GetDefaultOptions();
std::string file_path = sst_files_dir_ + ToString(1); std::string file_path = sst_files_dir_ + std::to_string(1);
SstFileWriter sfw(EnvOptions(), options); SstFileWriter sfw(EnvOptions(), options);
ASSERT_OK(sfw.Open(file_path)); ASSERT_OK(sfw.Open(file_path));

View File

@ -118,7 +118,7 @@ class ExternalSSTFileTest
}); });
data.resize(uniq_iter - data.begin()); data.resize(uniq_iter - data.begin());
} }
std::string file_path = sst_files_dir_ + ToString(file_id); std::string file_path = sst_files_dir_ + std::to_string(file_id);
SstFileWriter sst_file_writer(EnvOptions(), options, cfh); SstFileWriter sst_file_writer(EnvOptions(), options, cfh);
Status s = sst_file_writer.Open(file_path); Status s = sst_file_writer.Open(file_path);
if (!s.ok()) { if (!s.ok()) {
@ -172,7 +172,7 @@ class ExternalSSTFileTest
}); });
data.resize(uniq_iter - data.begin()); data.resize(uniq_iter - data.begin());
} }
std::string file_path = sst_files_dir_ + ToString(file_id); std::string file_path = sst_files_dir_ + std::to_string(file_id);
SstFileWriter sst_file_writer(EnvOptions(), options, cfh); SstFileWriter sst_file_writer(EnvOptions(), options, cfh);
Status s = sst_file_writer.Open(file_path); Status s = sst_file_writer.Open(file_path);
@ -270,7 +270,7 @@ class ExternalSSTFileTest
ColumnFamilyHandle* cfh = nullptr) { ColumnFamilyHandle* cfh = nullptr) {
std::vector<std::pair<std::string, std::string>> file_data; std::vector<std::pair<std::string, std::string>> file_data;
for (auto& k : keys) { for (auto& k : keys) {
file_data.emplace_back(Key(k), Key(k) + ToString(file_id)); file_data.emplace_back(Key(k), Key(k) + std::to_string(file_id));
} }
return GenerateAndAddExternalFile(options, file_data, file_id, return GenerateAndAddExternalFile(options, file_data, file_id,
allow_global_seqno, write_global_seqno, allow_global_seqno, write_global_seqno,
@ -966,7 +966,7 @@ TEST_F(ExternalSSTFileTest, MultiThreaded) {
// Generate file names // Generate file names
std::vector<std::string> file_names; std::vector<std::string> file_names;
for (int i = 0; i < num_files; i++) { for (int i = 0; i < num_files; i++) {
std::string file_name = "file_" + ToString(i) + ".sst"; std::string file_name = "file_" + std::to_string(i) + ".sst";
file_names.push_back(sst_files_dir_ + file_name); file_names.push_back(sst_files_dir_ + file_name);
} }
@ -1116,7 +1116,7 @@ TEST_F(ExternalSSTFileTest, OverlappingRanges) {
int range_end = key_ranges[i].second; int range_end = key_ranges[i].second;
Status s; Status s;
std::string range_val = "range_" + ToString(i); std::string range_val = "range_" + std::to_string(i);
// For 20% of ranges we use DB::Put, for 80% we use DB::AddFile // For 20% of ranges we use DB::Put, for 80% we use DB::AddFile
if (i && i % 5 == 0) { if (i && i % 5 == 0) {
@ -1456,7 +1456,7 @@ TEST_F(ExternalSSTFileTest, CompactDuringAddFileRandom) {
ASSERT_EQ(Get(Key(range_start)), Key(range_start)) << rid; ASSERT_EQ(Get(Key(range_start)), Key(range_start)) << rid;
ASSERT_EQ(Get(Key(range_end)), Key(range_end)) << rid; ASSERT_EQ(Get(Key(range_end)), Key(range_end)) << rid;
for (int k = range_start + 1; k < range_end; k++) { for (int k = range_start + 1; k < range_end; k++) {
std::string v = Key(k) + ToString(rid); std::string v = Key(k) + std::to_string(rid);
ASSERT_EQ(Get(Key(k)), v) << rid; ASSERT_EQ(Get(Key(k)), v) << rid;
} }
} }

View File

@ -931,9 +931,9 @@ Status FlushJob::WriteLevel0Table() {
assert(!s.ok() || io_s.ok()); assert(!s.ok() || io_s.ok());
io_s.PermitUncheckedError(); io_s.PermitUncheckedError();
if (num_input_entries != total_num_entries && s.ok()) { if (num_input_entries != total_num_entries && s.ok()) {
std::string msg = "Expected " + ToString(total_num_entries) + std::string msg = "Expected " + std::to_string(total_num_entries) +
" entries in memtables, but read " + " entries in memtables, but read " +
ToString(num_input_entries); std::to_string(num_input_entries);
ROCKS_LOG_WARN(db_options_.info_log, "[%s] [JOB %d] Level-0 flush %s", ROCKS_LOG_WARN(db_options_.info_log, "[%s] [JOB %d] Level-0 flush %s",
cfd_->GetName().c_str(), job_context_->job_id, cfd_->GetName().c_str(), job_context_->job_id,
msg.c_str()); msg.c_str());

View File

@ -191,7 +191,7 @@ TEST_F(FlushJobTest, NonEmpty) {
// range-delete "9995" -> "9999" at seqno 10000 // range-delete "9995" -> "9999" at seqno 10000
// blob references with seqnos 10001..10006 // blob references with seqnos 10001..10006
for (int i = 1; i < 10000; ++i) { for (int i = 1; i < 10000; ++i) {
std::string key(ToString((i + 1000) % 10000)); std::string key(std::to_string((i + 1000) % 10000));
std::string value("value" + key); std::string value("value" + key);
ASSERT_OK(new_mem->Add(SequenceNumber(i), kTypeValue, key, value, ASSERT_OK(new_mem->Add(SequenceNumber(i), kTypeValue, key, value,
nullptr /* kv_prot_info */)); nullptr /* kv_prot_info */));
@ -214,7 +214,7 @@ TEST_F(FlushJobTest, NonEmpty) {
constexpr std::array<uint64_t, 6> blob_file_numbers{{ constexpr std::array<uint64_t, 6> blob_file_numbers{{
kInvalidBlobFileNumber, 5, 103, 17, 102, 101}}; kInvalidBlobFileNumber, 5, 103, 17, 102, 101}};
for (size_t i = 0; i < blob_file_numbers.size(); ++i) { for (size_t i = 0; i < blob_file_numbers.size(); ++i) {
std::string key(ToString(i + 10001)); std::string key(std::to_string(i + 10001));
std::string blob_index; std::string blob_index;
if (i == 0) { if (i == 0) {
BlobIndex::EncodeInlinedTTL(&blob_index, /* expiration */ 1234567890ULL, BlobIndex::EncodeInlinedTTL(&blob_index, /* expiration */ 1234567890ULL,
@ -265,7 +265,7 @@ TEST_F(FlushJobTest, NonEmpty) {
db_options_.statistics->histogramData(FLUSH_TIME, &hist); db_options_.statistics->histogramData(FLUSH_TIME, &hist);
ASSERT_GT(hist.average, 0.0); ASSERT_GT(hist.average, 0.0);
ASSERT_EQ(ToString(0), file_meta.smallest.user_key().ToString()); ASSERT_EQ(std::to_string(0), file_meta.smallest.user_key().ToString());
ASSERT_EQ("9999a", file_meta.largest.user_key().ToString()); ASSERT_EQ("9999a", file_meta.largest.user_key().ToString());
ASSERT_EQ(1, file_meta.fd.smallest_seqno); ASSERT_EQ(1, file_meta.fd.smallest_seqno);
ASSERT_EQ(10006, file_meta.fd.largest_seqno); ASSERT_EQ(10006, file_meta.fd.largest_seqno);
@ -291,7 +291,7 @@ TEST_F(FlushJobTest, FlushMemTablesSingleColumnFamily) {
memtable_ids.push_back(mem->GetID()); memtable_ids.push_back(mem->GetID());
for (size_t j = 0; j < num_keys_per_table; ++j) { for (size_t j = 0; j < num_keys_per_table; ++j) {
std::string key(ToString(j + i * num_keys_per_table)); std::string key(std::to_string(j + i * num_keys_per_table));
std::string value("value" + key); std::string value("value" + key);
ASSERT_OK(mem->Add(SequenceNumber(j + i * num_keys_per_table), kTypeValue, ASSERT_OK(mem->Add(SequenceNumber(j + i * num_keys_per_table), kTypeValue,
key, value, nullptr /* kv_prot_info */)); key, value, nullptr /* kv_prot_info */));
@ -326,7 +326,7 @@ TEST_F(FlushJobTest, FlushMemTablesSingleColumnFamily) {
db_options_.statistics->histogramData(FLUSH_TIME, &hist); db_options_.statistics->histogramData(FLUSH_TIME, &hist);
ASSERT_GT(hist.average, 0.0); ASSERT_GT(hist.average, 0.0);
ASSERT_EQ(ToString(0), file_meta.smallest.user_key().ToString()); ASSERT_EQ(std::to_string(0), file_meta.smallest.user_key().ToString());
ASSERT_EQ("99", file_meta.largest.user_key().ToString()); ASSERT_EQ("99", file_meta.largest.user_key().ToString());
ASSERT_EQ(0, file_meta.fd.smallest_seqno); ASSERT_EQ(0, file_meta.fd.smallest_seqno);
ASSERT_EQ(SequenceNumber(num_mems_to_flush * num_keys_per_table - 1), ASSERT_EQ(SequenceNumber(num_mems_to_flush * num_keys_per_table - 1),
@ -364,7 +364,7 @@ TEST_F(FlushJobTest, FlushMemtablesMultipleColumnFamilies) {
mem->Ref(); mem->Ref();
for (size_t j = 0; j != num_keys_per_memtable; ++j) { for (size_t j = 0; j != num_keys_per_memtable; ++j) {
std::string key(ToString(j + i * num_keys_per_memtable)); std::string key(std::to_string(j + i * num_keys_per_memtable));
std::string value("value" + key); std::string value("value" + key);
ASSERT_OK(mem->Add(curr_seqno++, kTypeValue, key, value, ASSERT_OK(mem->Add(curr_seqno++, kTypeValue, key, value,
nullptr /* kv_prot_info */)); nullptr /* kv_prot_info */));
@ -439,7 +439,7 @@ TEST_F(FlushJobTest, FlushMemtablesMultipleColumnFamilies) {
ASSERT_GT(hist.average, 0.0); ASSERT_GT(hist.average, 0.0);
k = 0; k = 0;
for (const auto& file_meta : file_metas) { for (const auto& file_meta : file_metas) {
ASSERT_EQ(ToString(0), file_meta.smallest.user_key().ToString()); ASSERT_EQ(std::to_string(0), file_meta.smallest.user_key().ToString());
ASSERT_EQ("999", file_meta.largest.user_key() ASSERT_EQ("999", file_meta.largest.user_key()
.ToString()); // max key by bytewise comparator .ToString()); // max key by bytewise comparator
ASSERT_EQ(smallest_seqs[k], file_meta.fd.smallest_seqno); ASSERT_EQ(smallest_seqs[k], file_meta.fd.smallest_seqno);
@ -480,7 +480,7 @@ TEST_F(FlushJobTest, Snapshots) {
SequenceNumber current_seqno = 0; SequenceNumber current_seqno = 0;
auto inserted_keys = mock::MakeMockFile(); auto inserted_keys = mock::MakeMockFile();
for (int i = 1; i < keys; ++i) { for (int i = 1; i < keys; ++i) {
std::string key(ToString(i)); std::string key(std::to_string(i));
int insertions = rnd.Uniform(max_inserts_per_keys); int insertions = rnd.Uniform(max_inserts_per_keys);
for (int j = 0; j < insertions; ++j) { for (int j = 0; j < insertions; ++j) {
std::string value(rnd.HumanReadableString(10)); std::string value(rnd.HumanReadableString(10));

View File

@ -604,7 +604,7 @@ bool ForwardIterator::PrepareValue() {
Status ForwardIterator::GetProperty(std::string prop_name, std::string* prop) { Status ForwardIterator::GetProperty(std::string prop_name, std::string* prop) {
assert(prop != nullptr); assert(prop != nullptr);
if (prop_name == "rocksdb.iterator.super-version-number") { if (prop_name == "rocksdb.iterator.super-version-number") {
*prop = ToString(sv_->version_number); *prop = std::to_string(sv_->version_number);
return Status::OK(); return Status::OK();
} }
return Status::InvalidArgument(); return Status::InvalidArgument();

View File

@ -704,20 +704,19 @@ void InternalStats::CacheEntryRoleStats::ToMap(
auto& v = *values; auto& v = *values;
v[BlockCacheEntryStatsMapKeys::CacheId()] = cache_id; v[BlockCacheEntryStatsMapKeys::CacheId()] = cache_id;
v[BlockCacheEntryStatsMapKeys::CacheCapacityBytes()] = v[BlockCacheEntryStatsMapKeys::CacheCapacityBytes()] =
ROCKSDB_NAMESPACE::ToString(cache_capacity); std::to_string(cache_capacity);
v[BlockCacheEntryStatsMapKeys::LastCollectionDurationSeconds()] = v[BlockCacheEntryStatsMapKeys::LastCollectionDurationSeconds()] =
ROCKSDB_NAMESPACE::ToString(GetLastDurationMicros() / 1000000.0); std::to_string(GetLastDurationMicros() / 1000000.0);
v[BlockCacheEntryStatsMapKeys::LastCollectionAgeSeconds()] = v[BlockCacheEntryStatsMapKeys::LastCollectionAgeSeconds()] =
ROCKSDB_NAMESPACE::ToString((clock->NowMicros() - last_end_time_micros_) / std::to_string((clock->NowMicros() - last_end_time_micros_) / 1000000U);
1000000U);
for (size_t i = 0; i < kNumCacheEntryRoles; ++i) { for (size_t i = 0; i < kNumCacheEntryRoles; ++i) {
auto role = static_cast<CacheEntryRole>(i); auto role = static_cast<CacheEntryRole>(i);
v[BlockCacheEntryStatsMapKeys::EntryCount(role)] = v[BlockCacheEntryStatsMapKeys::EntryCount(role)] =
ROCKSDB_NAMESPACE::ToString(entry_counts[i]); std::to_string(entry_counts[i]);
v[BlockCacheEntryStatsMapKeys::UsedBytes(role)] = v[BlockCacheEntryStatsMapKeys::UsedBytes(role)] =
ROCKSDB_NAMESPACE::ToString(total_charges[i]); std::to_string(total_charges[i]);
v[BlockCacheEntryStatsMapKeys::UsedPercent(role)] = v[BlockCacheEntryStatsMapKeys::UsedPercent(role)] =
ROCKSDB_NAMESPACE::ToString(100.0 * total_charges[i] / cache_capacity); std::to_string(100.0 * total_charges[i] / cache_capacity);
} }
} }
@ -763,7 +762,7 @@ bool InternalStats::HandleLiveSstFilesSizeAtTemperature(std::string* value,
} }
} }
*value = ToString(size); *value = std::to_string(size);
return true; return true;
} }
@ -919,7 +918,7 @@ bool InternalStats::HandleCompressionRatioAtLevelPrefix(std::string* value,
if (!ok || level >= static_cast<uint64_t>(number_levels_)) { if (!ok || level >= static_cast<uint64_t>(number_levels_)) {
return false; return false;
} }
*value = ToString( *value = std::to_string(
vstorage->GetEstimatedCompressionRatioAtLevel(static_cast<int>(level))); vstorage->GetEstimatedCompressionRatioAtLevel(static_cast<int>(level)));
return true; return true;
} }
@ -1006,7 +1005,7 @@ static std::map<std::string, std::string> MapUint64ValuesToString(
const std::map<std::string, uint64_t>& from) { const std::map<std::string, uint64_t>& from) {
std::map<std::string, std::string> to; std::map<std::string, std::string> to;
for (const auto& e : from) { for (const auto& e : from) {
to[e.first] = ToString(e.second); to[e.first] = std::to_string(e.second);
} }
return to; return to;
} }
@ -1500,7 +1499,7 @@ void InternalStats::DumpCFMapStats(
DumpCFMapStats(vstorage, &levels_stats, &compaction_stats_sum); DumpCFMapStats(vstorage, &levels_stats, &compaction_stats_sum);
for (auto const& level_ent : levels_stats) { for (auto const& level_ent : levels_stats) {
auto level_str = auto level_str =
level_ent.first == -1 ? "Sum" : "L" + ToString(level_ent.first); level_ent.first == -1 ? "Sum" : "L" + std::to_string(level_ent.first);
for (auto const& stat_ent : level_ent.second) { for (auto const& stat_ent : level_ent.second) {
auto stat_type = stat_ent.first; auto stat_type = stat_ent.first;
auto key_str = auto key_str =
@ -1651,7 +1650,8 @@ void InternalStats::DumpCFStatsNoFileHistogram(std::string* value) {
DumpCFMapStats(vstorage, &levels_stats, &compaction_stats_sum); DumpCFMapStats(vstorage, &levels_stats, &compaction_stats_sum);
for (int l = 0; l < number_levels_; ++l) { for (int l = 0; l < number_levels_; ++l) {
if (levels_stats.find(l) != levels_stats.end()) { if (levels_stats.find(l) != levels_stats.end()) {
PrintLevelStats(buf, sizeof(buf), "L" + ToString(l), levels_stats[l]); PrintLevelStats(buf, sizeof(buf), "L" + std::to_string(l),
levels_stats[l]);
value->append(buf); value->append(buf);
} }
} }

View File

@ -436,10 +436,10 @@ TEST_F(EventListenerTest, MultiDBMultiListeners) {
std::vector<std::vector<ColumnFamilyHandle *>> vec_handles; std::vector<std::vector<ColumnFamilyHandle *>> vec_handles;
for (int d = 0; d < kNumDBs; ++d) { for (int d = 0; d < kNumDBs; ++d) {
ASSERT_OK(DestroyDB(dbname_ + ToString(d), options)); ASSERT_OK(DestroyDB(dbname_ + std::to_string(d), options));
DB* db; DB* db;
std::vector<ColumnFamilyHandle*> handles; std::vector<ColumnFamilyHandle*> handles;
ASSERT_OK(DB::Open(options, dbname_ + ToString(d), &db)); ASSERT_OK(DB::Open(options, dbname_ + std::to_string(d), &db));
for (size_t c = 0; c < cf_names.size(); ++c) { for (size_t c = 0; c < cf_names.size(); ++c) {
ColumnFamilyHandle* handle; ColumnFamilyHandle* handle;
ASSERT_OK(db->CreateColumnFamily(cf_opts, cf_names[c], &handle)); ASSERT_OK(db->CreateColumnFamily(cf_opts, cf_names[c], &handle));
@ -527,7 +527,8 @@ TEST_F(EventListenerTest, DisableBGCompaction) {
// keep writing until writes are forced to stop. // keep writing until writes are forced to stop.
for (int i = 0; static_cast<int>(cf_meta.file_count) < kSlowdownTrigger * 10; for (int i = 0; static_cast<int>(cf_meta.file_count) < kSlowdownTrigger * 10;
++i) { ++i) {
ASSERT_OK(Put(1, ToString(i), std::string(10000, 'x'), WriteOptions())); ASSERT_OK(
Put(1, std::to_string(i), std::string(10000, 'x'), WriteOptions()));
FlushOptions fo; FlushOptions fo;
fo.allow_write_stall = true; fo.allow_write_stall = true;
ASSERT_OK(db_->Flush(fo, handles_[1])); ASSERT_OK(db_->Flush(fo, handles_[1]));

View File

@ -578,15 +578,15 @@ TEST_F(MemTableListTest, FlushPendingTest) {
std::string value; std::string value;
MergeContext merge_context; MergeContext merge_context;
ASSERT_OK(mem->Add(++seq, kTypeValue, "key1", ToString(i), ASSERT_OK(mem->Add(++seq, kTypeValue, "key1", std::to_string(i),
nullptr /* kv_prot_info */)); nullptr /* kv_prot_info */));
ASSERT_OK(mem->Add(++seq, kTypeValue, "keyN" + ToString(i), "valueN", ASSERT_OK(mem->Add(++seq, kTypeValue, "keyN" + std::to_string(i), "valueN",
nullptr /* kv_prot_info */)); nullptr /* kv_prot_info */));
ASSERT_OK(mem->Add(++seq, kTypeValue, "keyX" + ToString(i), "value", ASSERT_OK(mem->Add(++seq, kTypeValue, "keyX" + std::to_string(i), "value",
nullptr /* kv_prot_info */)); nullptr /* kv_prot_info */));
ASSERT_OK(mem->Add(++seq, kTypeValue, "keyM" + ToString(i), "valueM", ASSERT_OK(mem->Add(++seq, kTypeValue, "keyM" + std::to_string(i), "valueM",
nullptr /* kv_prot_info */)); nullptr /* kv_prot_info */));
ASSERT_OK(mem->Add(++seq, kTypeDeletion, "keyX" + ToString(i), "", ASSERT_OK(mem->Add(++seq, kTypeDeletion, "keyX" + std::to_string(i), "",
nullptr /* kv_prot_info */)); nullptr /* kv_prot_info */));
tables.push_back(mem); tables.push_back(mem);
@ -860,15 +860,15 @@ TEST_F(MemTableListTest, AtomicFlusTest) {
std::string value; std::string value;
ASSERT_OK(mem->Add(++seq, kTypeValue, "key1", ToString(i), ASSERT_OK(mem->Add(++seq, kTypeValue, "key1", std::to_string(i),
nullptr /* kv_prot_info */)); nullptr /* kv_prot_info */));
ASSERT_OK(mem->Add(++seq, kTypeValue, "keyN" + ToString(i), "valueN", ASSERT_OK(mem->Add(++seq, kTypeValue, "keyN" + std::to_string(i),
"valueN", nullptr /* kv_prot_info */));
ASSERT_OK(mem->Add(++seq, kTypeValue, "keyX" + std::to_string(i), "value",
nullptr /* kv_prot_info */)); nullptr /* kv_prot_info */));
ASSERT_OK(mem->Add(++seq, kTypeValue, "keyX" + ToString(i), "value", ASSERT_OK(mem->Add(++seq, kTypeValue, "keyM" + std::to_string(i),
nullptr /* kv_prot_info */)); "valueM", nullptr /* kv_prot_info */));
ASSERT_OK(mem->Add(++seq, kTypeValue, "keyM" + ToString(i), "valueM", ASSERT_OK(mem->Add(++seq, kTypeDeletion, "keyX" + std::to_string(i), "",
nullptr /* kv_prot_info */));
ASSERT_OK(mem->Add(++seq, kTypeDeletion, "keyX" + ToString(i), "",
nullptr /* kv_prot_info */)); nullptr /* kv_prot_info */));
elem.push_back(mem); elem.push_back(mem);

View File

@ -41,7 +41,7 @@ class ObsoleteFilesTest : public DBTestBase {
WriteOptions options; WriteOptions options;
options.sync = false; options.sync = false;
for (int i = startkey; i < (numkeys + startkey) ; i++) { for (int i = startkey; i < (numkeys + startkey) ; i++) {
std::string temp = ToString(i); std::string temp = std::to_string(i);
Slice key(temp); Slice key(temp);
Slice value(temp); Slice value(temp);
ASSERT_OK(db_->Put(options, key, value)); ASSERT_OK(db_->Put(options, key, value));

View File

@ -75,21 +75,21 @@ TEST_F(PerfContextTest, SeekIntoDeletion) {
ReadOptions read_options; ReadOptions read_options;
for (int i = 0; i < FLAGS_total_keys; ++i) { for (int i = 0; i < FLAGS_total_keys; ++i) {
std::string key = "k" + ToString(i); std::string key = "k" + std::to_string(i);
std::string value = "v" + ToString(i); std::string value = "v" + std::to_string(i);
ASSERT_OK(db->Put(write_options, key, value)); ASSERT_OK(db->Put(write_options, key, value));
} }
for (int i = 0; i < FLAGS_total_keys -1 ; ++i) { for (int i = 0; i < FLAGS_total_keys -1 ; ++i) {
std::string key = "k" + ToString(i); std::string key = "k" + std::to_string(i);
ASSERT_OK(db->Delete(write_options, key)); ASSERT_OK(db->Delete(write_options, key));
} }
HistogramImpl hist_get; HistogramImpl hist_get;
HistogramImpl hist_get_time; HistogramImpl hist_get_time;
for (int i = 0; i < FLAGS_total_keys - 1; ++i) { for (int i = 0; i < FLAGS_total_keys - 1; ++i) {
std::string key = "k" + ToString(i); std::string key = "k" + std::to_string(i);
std::string value; std::string value;
get_perf_context()->Reset(); get_perf_context()->Reset();
@ -130,7 +130,7 @@ TEST_F(PerfContextTest, SeekIntoDeletion) {
HistogramImpl hist_seek; HistogramImpl hist_seek;
for (int i = 0; i < FLAGS_total_keys; ++i) { for (int i = 0; i < FLAGS_total_keys; ++i) {
std::unique_ptr<Iterator> iter(db->NewIterator(read_options)); std::unique_ptr<Iterator> iter(db->NewIterator(read_options));
std::string key = "k" + ToString(i); std::string key = "k" + std::to_string(i);
get_perf_context()->Reset(); get_perf_context()->Reset();
StopWatchNano timer(SystemClock::Default().get(), true); StopWatchNano timer(SystemClock::Default().get(), true);
@ -265,8 +265,8 @@ void ProfileQueries(bool enabled_time = false) {
continue; continue;
} }
std::string key = "k" + ToString(i); std::string key = "k" + std::to_string(i);
std::string value = "v" + ToString(i); std::string value = "v" + std::to_string(i);
std::vector<std::string> values; std::vector<std::string> values;
@ -297,8 +297,8 @@ void ProfileQueries(bool enabled_time = false) {
if (i == kFlushFlag) { if (i == kFlushFlag) {
continue; continue;
} }
std::string key = "k" + ToString(i); std::string key = "k" + std::to_string(i);
std::string expected_value = "v" + ToString(i); std::string expected_value = "v" + std::to_string(i);
std::string value; std::string value;
std::vector<Slice> multiget_keys = {Slice(key)}; std::vector<Slice> multiget_keys = {Slice(key)};
@ -415,8 +415,8 @@ void ProfileQueries(bool enabled_time = false) {
if (i == kFlushFlag) { if (i == kFlushFlag) {
continue; continue;
} }
std::string key = "k" + ToString(i); std::string key = "k" + std::to_string(i);
std::string expected_value = "v" + ToString(i); std::string expected_value = "v" + std::to_string(i);
std::string value; std::string value;
std::vector<Slice> multiget_keys = {Slice(key)}; std::vector<Slice> multiget_keys = {Slice(key)};
@ -543,8 +543,8 @@ TEST_F(PerfContextTest, SeekKeyComparison) {
SetPerfLevel(kEnableTime); SetPerfLevel(kEnableTime);
StopWatchNano timer(SystemClock::Default().get()); StopWatchNano timer(SystemClock::Default().get());
for (const int i : keys) { for (const int i : keys) {
std::string key = "k" + ToString(i); std::string key = "k" + std::to_string(i);
std::string value = "v" + ToString(i); std::string value = "v" + std::to_string(i);
get_perf_context()->Reset(); get_perf_context()->Reset();
timer.Start(); timer.Start();
@ -565,8 +565,8 @@ TEST_F(PerfContextTest, SeekKeyComparison) {
HistogramImpl hist_next; HistogramImpl hist_next;
for (int i = 0; i < FLAGS_total_keys; ++i) { for (int i = 0; i < FLAGS_total_keys; ++i) {
std::string key = "k" + ToString(i); std::string key = "k" + std::to_string(i);
std::string value = "v" + ToString(i); std::string value = "v" + std::to_string(i);
std::unique_ptr<Iterator> iter(db->NewIterator(read_options)); std::unique_ptr<Iterator> iter(db->NewIterator(read_options));
get_perf_context()->Reset(); get_perf_context()->Reset();
@ -841,7 +841,7 @@ TEST_F(PerfContextTest, CPUTimer) {
std::string max_str = "0"; std::string max_str = "0";
for (int i = 0; i < FLAGS_total_keys; ++i) { for (int i = 0; i < FLAGS_total_keys; ++i) {
std::string i_str = ToString(i); std::string i_str = std::to_string(i);
std::string key = "k" + i_str; std::string key = "k" + i_str;
std::string value = "v" + i_str; std::string value = "v" + i_str;
max_str = max_str > i_str ? max_str : i_str; max_str = max_str > i_str ? max_str : i_str;
@ -935,9 +935,9 @@ TEST_F(PerfContextTest, CPUTimer) {
get_perf_context()->Reset(); get_perf_context()->Reset();
auto count = get_perf_context()->iter_seek_cpu_nanos; auto count = get_perf_context()->iter_seek_cpu_nanos;
for (int i = 0; i < FLAGS_total_keys; ++i) { for (int i = 0; i < FLAGS_total_keys; ++i) {
iter->Seek("k" + ToString(i)); iter->Seek("k" + std::to_string(i));
ASSERT_TRUE(iter->Valid()); ASSERT_TRUE(iter->Valid());
ASSERT_EQ("v" + ToString(i), iter->value().ToString()); ASSERT_EQ("v" + std::to_string(i), iter->value().ToString());
auto next_count = get_perf_context()->iter_seek_cpu_nanos; auto next_count = get_perf_context()->iter_seek_cpu_nanos;
ASSERT_GT(next_count, count); ASSERT_GT(next_count, count);
count = next_count; count = next_count;

View File

@ -220,8 +220,8 @@ class PlainTableDBTest : public testing::Test,
int NumTableFilesAtLevel(int level) { int NumTableFilesAtLevel(int level) {
std::string property; std::string property;
EXPECT_TRUE(db_->GetProperty("rocksdb.num-files-at-level" + ToString(level), EXPECT_TRUE(db_->GetProperty(
&property)); "rocksdb.num-files-at-level" + std::to_string(level), &property));
return atoi(property.c_str()); return atoi(property.c_str());
} }
@ -889,7 +889,7 @@ TEST_P(PlainTableDBTest, IteratorLargeKeys) {
}; };
for (size_t i = 0; i < 7; i++) { for (size_t i = 0; i < 7; i++) {
ASSERT_OK(Put(key_list[i], ToString(i))); ASSERT_OK(Put(key_list[i], std::to_string(i)));
} }
ASSERT_OK(dbfull()->TEST_FlushMemTable()); ASSERT_OK(dbfull()->TEST_FlushMemTable());
@ -900,7 +900,7 @@ TEST_P(PlainTableDBTest, IteratorLargeKeys) {
for (size_t i = 0; i < 7; i++) { for (size_t i = 0; i < 7; i++) {
ASSERT_TRUE(iter->Valid()); ASSERT_TRUE(iter->Valid());
ASSERT_EQ(key_list[i], iter->key().ToString()); ASSERT_EQ(key_list[i], iter->key().ToString());
ASSERT_EQ(ToString(i), iter->value().ToString()); ASSERT_EQ(std::to_string(i), iter->value().ToString());
iter->Next(); iter->Next();
} }
@ -937,7 +937,7 @@ TEST_P(PlainTableDBTest, IteratorLargeKeysWithPrefix) {
MakeLongKeyWithPrefix(26, '6')}; MakeLongKeyWithPrefix(26, '6')};
for (size_t i = 0; i < 7; i++) { for (size_t i = 0; i < 7; i++) {
ASSERT_OK(Put(key_list[i], ToString(i))); ASSERT_OK(Put(key_list[i], std::to_string(i)));
} }
ASSERT_OK(dbfull()->TEST_FlushMemTable()); ASSERT_OK(dbfull()->TEST_FlushMemTable());
@ -948,7 +948,7 @@ TEST_P(PlainTableDBTest, IteratorLargeKeysWithPrefix) {
for (size_t i = 0; i < 7; i++) { for (size_t i = 0; i < 7; i++) {
ASSERT_TRUE(iter->Valid()); ASSERT_TRUE(iter->Valid());
ASSERT_EQ(key_list[i], iter->key().ToString()); ASSERT_EQ(key_list[i], iter->key().ToString());
ASSERT_EQ(ToString(i), iter->value().ToString()); ASSERT_EQ(std::to_string(i), iter->value().ToString());
iter->Next(); iter->Next();
} }

View File

@ -628,7 +628,7 @@ TEST_F(PrefixTest, DynamicPrefixIterator) {
TestKey test_key(prefix, FLAGS_items_per_prefix / 2); TestKey test_key(prefix, FLAGS_items_per_prefix / 2);
std::string s; std::string s;
Slice key = TestKeyToSlice(s, test_key); Slice key = TestKeyToSlice(s, test_key);
std::string value = "v" + ToString(0); std::string value = "v" + std::to_string(0);
get_perf_context()->Reset(); get_perf_context()->Reset();
StopWatchNano timer(SystemClock::Default().get(), true); StopWatchNano timer(SystemClock::Default().get(), true);

View File

@ -147,7 +147,7 @@ class Repairer {
const auto* cf_opts = GetColumnFamilyOptions(cf_name); const auto* cf_opts = GetColumnFamilyOptions(cf_name);
if (cf_opts == nullptr) { if (cf_opts == nullptr) {
return Status::Corruption("Encountered unknown column family with name=" + return Status::Corruption("Encountered unknown column family with name=" +
cf_name + ", id=" + ToString(cf_id)); cf_name + ", id=" + std::to_string(cf_id));
} }
Options opts(db_options_, *cf_opts); Options opts(db_options_, *cf_opts);
MutableCFOptions mut_cf_opts(opts); MutableCFOptions mut_cf_opts(opts);

View File

@ -289,7 +289,7 @@ TEST_F(RepairTest, RepairMultipleColumnFamilies) {
CreateAndReopenWithCF({"pikachu1", "pikachu2"}, CurrentOptions()); CreateAndReopenWithCF({"pikachu1", "pikachu2"}, CurrentOptions());
for (int i = 0; i < kNumCfs; ++i) { for (int i = 0; i < kNumCfs; ++i) {
for (int j = 0; j < kEntriesPerCf; ++j) { for (int j = 0; j < kEntriesPerCf; ++j) {
ASSERT_OK(Put(i, "key" + ToString(j), "val" + ToString(j))); ASSERT_OK(Put(i, "key" + std::to_string(j), "val" + std::to_string(j)));
if (j == kEntriesPerCf - 1 && i == kNumCfs - 1) { if (j == kEntriesPerCf - 1 && i == kNumCfs - 1) {
// Leave one unflushed so we can verify WAL entries are properly // Leave one unflushed so we can verify WAL entries are properly
// associated with column families. // associated with column families.
@ -313,7 +313,7 @@ TEST_F(RepairTest, RepairMultipleColumnFamilies) {
CurrentOptions()); CurrentOptions());
for (int i = 0; i < kNumCfs; ++i) { for (int i = 0; i < kNumCfs; ++i) {
for (int j = 0; j < kEntriesPerCf; ++j) { for (int j = 0; j < kEntriesPerCf; ++j) {
ASSERT_EQ(Get(i, "key" + ToString(j)), "val" + ToString(j)); ASSERT_EQ(Get(i, "key" + std::to_string(j)), "val" + std::to_string(j));
} }
} }
} }
@ -334,7 +334,7 @@ TEST_F(RepairTest, RepairColumnFamilyOptions) {
std::vector<Options>{opts, rev_opts}); std::vector<Options>{opts, rev_opts});
for (int i = 0; i < kNumCfs; ++i) { for (int i = 0; i < kNumCfs; ++i) {
for (int j = 0; j < kEntriesPerCf; ++j) { for (int j = 0; j < kEntriesPerCf; ++j) {
ASSERT_OK(Put(i, "key" + ToString(j), "val" + ToString(j))); ASSERT_OK(Put(i, "key" + std::to_string(j), "val" + std::to_string(j)));
if (i == kNumCfs - 1 && j == kEntriesPerCf - 1) { if (i == kNumCfs - 1 && j == kEntriesPerCf - 1) {
// Leave one unflushed so we can verify RepairDB's flush logic // Leave one unflushed so we can verify RepairDB's flush logic
continue; continue;
@ -352,7 +352,7 @@ TEST_F(RepairTest, RepairColumnFamilyOptions) {
std::vector<Options>{opts, rev_opts})); std::vector<Options>{opts, rev_opts}));
for (int i = 0; i < kNumCfs; ++i) { for (int i = 0; i < kNumCfs; ++i) {
for (int j = 0; j < kEntriesPerCf; ++j) { for (int j = 0; j < kEntriesPerCf; ++j) {
ASSERT_EQ(Get(i, "key" + ToString(j)), "val" + ToString(j)); ASSERT_EQ(Get(i, "key" + std::to_string(j)), "val" + std::to_string(j));
} }
} }
@ -377,7 +377,7 @@ TEST_F(RepairTest, RepairColumnFamilyOptions) {
std::vector<Options>{opts, rev_opts})); std::vector<Options>{opts, rev_opts}));
for (int i = 0; i < kNumCfs; ++i) { for (int i = 0; i < kNumCfs; ++i) {
for (int j = 0; j < kEntriesPerCf; ++j) { for (int j = 0; j < kEntriesPerCf; ++j) {
ASSERT_EQ(Get(i, "key" + ToString(j)), "val" + ToString(j)); ASSERT_EQ(Get(i, "key" + std::to_string(j)), "val" + std::to_string(j));
} }
} }
} }

View File

@ -1702,11 +1702,9 @@ TEST_F(VersionBuilderTest, EstimatedActiveKeys) {
const uint32_t kDeletionsPerFile = 100; const uint32_t kDeletionsPerFile = 100;
for (uint32_t i = 0; i < kNumFiles; ++i) { for (uint32_t i = 0; i < kNumFiles; ++i) {
Add(static_cast<int>(i / kFilesPerLevel), i + 1, Add(static_cast<int>(i / kFilesPerLevel), i + 1,
ToString((i + 100) * 1000).c_str(), std::to_string((i + 100) * 1000).c_str(),
ToString((i + 100) * 1000 + 999).c_str(), std::to_string((i + 100) * 1000 + 999).c_str(), 100U, 0, 100, 100,
100U, 0, 100, 100, kEntriesPerFile, kDeletionsPerFile, (i < kTotalSamples));
kEntriesPerFile, kDeletionsPerFile,
(i < kTotalSamples));
} }
// minus 2X for the number of deletion entries because: // minus 2X for the number of deletion entries because:
// 1x for deletion entry does not count as a data entry. // 1x for deletion entry does not count as a data entry.

View File

@ -817,7 +817,7 @@ std::string VersionEdit::DebugString(bool hex_key) const {
r.append(" temperature: "); r.append(" temperature: ");
// Maybe change to human readable format whenthe feature becomes // Maybe change to human readable format whenthe feature becomes
// permanent // permanent
r.append(ToString(static_cast<int>(f.temperature))); r.append(std::to_string(static_cast<int>(f.temperature)));
} }
} }
@ -928,7 +928,7 @@ std::string VersionEdit::DebugJSON(int edit_num, bool hex_key) const {
jw << "FileChecksum" << Slice(f.file_checksum).ToString(true); jw << "FileChecksum" << Slice(f.file_checksum).ToString(true);
jw << "FileChecksumFuncName" << f.file_checksum_func_name; jw << "FileChecksumFuncName" << f.file_checksum_func_name;
if (f.temperature != Temperature::kUnknown) { if (f.temperature != Temperature::kUnknown) {
jw << "temperature" << ToString(static_cast<int>(f.temperature)); jw << "temperature" << std::to_string(static_cast<int>(f.temperature));
} }
if (f.oldest_blob_file_number != kInvalidBlobFileNumber) { if (f.oldest_blob_file_number != kInvalidBlobFileNumber) {
jw << "OldestBlobFile" << f.oldest_blob_file_number; jw << "OldestBlobFile" << f.oldest_blob_file_number;

View File

@ -3986,7 +3986,7 @@ std::string Version::DebugString(bool hex, bool print_stats) const {
} }
if (print_stats) { if (print_stats) {
r.append("("); r.append("(");
r.append(ToString( r.append(std::to_string(
files[i]->stats.num_reads_sampled.load(std::memory_order_relaxed))); files[i]->stats.num_reads_sampled.load(std::memory_order_relaxed)));
r.append(")"); r.append(")");
} }

View File

@ -378,9 +378,8 @@ Status WalManager::ReadFirstRecord(const WalFileType type,
*sequence = 0; *sequence = 0;
if (type != kAliveLogFile && type != kArchivedLogFile) { if (type != kAliveLogFile && type != kArchivedLogFile) {
ROCKS_LOG_ERROR(db_options_.info_log, "[WalManger] Unknown file type %s", ROCKS_LOG_ERROR(db_options_.info_log, "[WalManger] Unknown file type %s",
ToString(type).c_str()); std::to_string(type).c_str());
return Status::NotSupported( return Status::NotSupported("File Type Not Known " + std::to_string(type));
"File Type Not Known " + ToString(type));
} }
{ {
MutexLock l(&read_first_record_cache_mutex_); MutexLock l(&read_first_record_cache_mutex_);

View File

@ -94,7 +94,7 @@ class WalManagerTest : public testing::Test {
for (int i = 1; i <= num_logs; ++i) { for (int i = 1; i <= num_logs; ++i) {
RollTheLog(true); RollTheLog(true);
for (int k = 0; k < entries_per_log; ++k) { for (int k = 0; k < entries_per_log; ++k) {
Put(ToString(k), std::string(1024, 'a')); Put(std::to_string(k), std::string(1024, 'a'));
} }
} }
} }

View File

@ -118,7 +118,7 @@ static std::string PrintContents(WriteBatch* b,
break; break;
} }
state.append("@"); state.append("@");
state.append(ToString(ikey.sequence)); state.append(std::to_string(ikey.sequence));
} }
EXPECT_OK(iter->status()); EXPECT_OK(iter->status());
} }
@ -253,7 +253,7 @@ namespace {
if (column_family_id == 0) { if (column_family_id == 0) {
seen += "Put(" + key.ToString() + ", " + value.ToString() + ")"; seen += "Put(" + key.ToString() + ", " + value.ToString() + ")";
} else { } else {
seen += "PutCF(" + ToString(column_family_id) + ", " + seen += "PutCF(" + std::to_string(column_family_id) + ", " +
key.ToString() + ", " + value.ToString() + ")"; key.ToString() + ", " + value.ToString() + ")";
} }
return Status::OK(); return Status::OK();
@ -262,7 +262,7 @@ namespace {
if (column_family_id == 0) { if (column_family_id == 0) {
seen += "Delete(" + key.ToString() + ")"; seen += "Delete(" + key.ToString() + ")";
} else { } else {
seen += "DeleteCF(" + ToString(column_family_id) + ", " + seen += "DeleteCF(" + std::to_string(column_family_id) + ", " +
key.ToString() + ")"; key.ToString() + ")";
} }
return Status::OK(); return Status::OK();
@ -272,7 +272,7 @@ namespace {
if (column_family_id == 0) { if (column_family_id == 0) {
seen += "SingleDelete(" + key.ToString() + ")"; seen += "SingleDelete(" + key.ToString() + ")";
} else { } else {
seen += "SingleDeleteCF(" + ToString(column_family_id) + ", " + seen += "SingleDeleteCF(" + std::to_string(column_family_id) + ", " +
key.ToString() + ")"; key.ToString() + ")";
} }
return Status::OK(); return Status::OK();
@ -283,7 +283,7 @@ namespace {
seen += "DeleteRange(" + begin_key.ToString() + ", " + seen += "DeleteRange(" + begin_key.ToString() + ", " +
end_key.ToString() + ")"; end_key.ToString() + ")";
} else { } else {
seen += "DeleteRangeCF(" + ToString(column_family_id) + ", " + seen += "DeleteRangeCF(" + std::to_string(column_family_id) + ", " +
begin_key.ToString() + ", " + end_key.ToString() + ")"; begin_key.ToString() + ", " + end_key.ToString() + ")";
} }
return Status::OK(); return Status::OK();
@ -293,7 +293,7 @@ namespace {
if (column_family_id == 0) { if (column_family_id == 0) {
seen += "Merge(" + key.ToString() + ", " + value.ToString() + ")"; seen += "Merge(" + key.ToString() + ", " + value.ToString() + ")";
} else { } else {
seen += "MergeCF(" + ToString(column_family_id) + ", " + seen += "MergeCF(" + std::to_string(column_family_id) + ", " +
key.ToString() + ", " + value.ToString() + ")"; key.ToString() + ", " + value.ToString() + ")";
} }
return Status::OK(); return Status::OK();

View File

@ -185,69 +185,69 @@ bool StressTest::BuildOptionsTable() {
std::unordered_map<std::string, std::vector<std::string>> options_tbl = { std::unordered_map<std::string, std::vector<std::string>> options_tbl = {
{"write_buffer_size", {"write_buffer_size",
{ToString(options_.write_buffer_size), {std::to_string(options_.write_buffer_size),
ToString(options_.write_buffer_size * 2), std::to_string(options_.write_buffer_size * 2),
ToString(options_.write_buffer_size * 4)}}, std::to_string(options_.write_buffer_size * 4)}},
{"max_write_buffer_number", {"max_write_buffer_number",
{ToString(options_.max_write_buffer_number), {std::to_string(options_.max_write_buffer_number),
ToString(options_.max_write_buffer_number * 2), std::to_string(options_.max_write_buffer_number * 2),
ToString(options_.max_write_buffer_number * 4)}}, std::to_string(options_.max_write_buffer_number * 4)}},
{"arena_block_size", {"arena_block_size",
{ {
ToString(options_.arena_block_size), std::to_string(options_.arena_block_size),
ToString(options_.write_buffer_size / 4), std::to_string(options_.write_buffer_size / 4),
ToString(options_.write_buffer_size / 8), std::to_string(options_.write_buffer_size / 8),
}}, }},
{"memtable_huge_page_size", {"0", ToString(2 * 1024 * 1024)}}, {"memtable_huge_page_size", {"0", std::to_string(2 * 1024 * 1024)}},
{"max_successive_merges", {"0", "2", "4"}}, {"max_successive_merges", {"0", "2", "4"}},
{"inplace_update_num_locks", {"100", "200", "300"}}, {"inplace_update_num_locks", {"100", "200", "300"}},
// TODO(ljin): enable test for this option // TODO(ljin): enable test for this option
// {"disable_auto_compactions", {"100", "200", "300"}}, // {"disable_auto_compactions", {"100", "200", "300"}},
{"level0_file_num_compaction_trigger", {"level0_file_num_compaction_trigger",
{ {
ToString(options_.level0_file_num_compaction_trigger), std::to_string(options_.level0_file_num_compaction_trigger),
ToString(options_.level0_file_num_compaction_trigger + 2), std::to_string(options_.level0_file_num_compaction_trigger + 2),
ToString(options_.level0_file_num_compaction_trigger + 4), std::to_string(options_.level0_file_num_compaction_trigger + 4),
}}, }},
{"level0_slowdown_writes_trigger", {"level0_slowdown_writes_trigger",
{ {
ToString(options_.level0_slowdown_writes_trigger), std::to_string(options_.level0_slowdown_writes_trigger),
ToString(options_.level0_slowdown_writes_trigger + 2), std::to_string(options_.level0_slowdown_writes_trigger + 2),
ToString(options_.level0_slowdown_writes_trigger + 4), std::to_string(options_.level0_slowdown_writes_trigger + 4),
}}, }},
{"level0_stop_writes_trigger", {"level0_stop_writes_trigger",
{ {
ToString(options_.level0_stop_writes_trigger), std::to_string(options_.level0_stop_writes_trigger),
ToString(options_.level0_stop_writes_trigger + 2), std::to_string(options_.level0_stop_writes_trigger + 2),
ToString(options_.level0_stop_writes_trigger + 4), std::to_string(options_.level0_stop_writes_trigger + 4),
}}, }},
{"max_compaction_bytes", {"max_compaction_bytes",
{ {
ToString(options_.target_file_size_base * 5), std::to_string(options_.target_file_size_base * 5),
ToString(options_.target_file_size_base * 15), std::to_string(options_.target_file_size_base * 15),
ToString(options_.target_file_size_base * 100), std::to_string(options_.target_file_size_base * 100),
}}, }},
{"target_file_size_base", {"target_file_size_base",
{ {
ToString(options_.target_file_size_base), std::to_string(options_.target_file_size_base),
ToString(options_.target_file_size_base * 2), std::to_string(options_.target_file_size_base * 2),
ToString(options_.target_file_size_base * 4), std::to_string(options_.target_file_size_base * 4),
}}, }},
{"target_file_size_multiplier", {"target_file_size_multiplier",
{ {
ToString(options_.target_file_size_multiplier), std::to_string(options_.target_file_size_multiplier),
"1", "1",
"2", "2",
}}, }},
{"max_bytes_for_level_base", {"max_bytes_for_level_base",
{ {
ToString(options_.max_bytes_for_level_base / 2), std::to_string(options_.max_bytes_for_level_base / 2),
ToString(options_.max_bytes_for_level_base), std::to_string(options_.max_bytes_for_level_base),
ToString(options_.max_bytes_for_level_base * 2), std::to_string(options_.max_bytes_for_level_base * 2),
}}, }},
{"max_bytes_for_level_multiplier", {"max_bytes_for_level_multiplier",
{ {
ToString(options_.max_bytes_for_level_multiplier), std::to_string(options_.max_bytes_for_level_multiplier),
"1", "1",
"2", "2",
}}, }},
@ -418,7 +418,7 @@ Status StressTest::AssertSame(DB* db, ColumnFamilyHandle* cf,
if (snap_state.status != s) { if (snap_state.status != s) {
return Status::Corruption( return Status::Corruption(
"The snapshot gave inconsistent results for key " + "The snapshot gave inconsistent results for key " +
ToString(Hash(snap_state.key.c_str(), snap_state.key.size(), 0)) + std::to_string(Hash(snap_state.key.c_str(), snap_state.key.size(), 0)) +
" in cf " + cf->GetName() + ": (" + snap_state.status.ToString() + " in cf " + cf->GetName() + ": (" + snap_state.status.ToString() +
") vs. (" + s.ToString() + ")"); ") vs. (" + s.ToString() + ")");
} }
@ -1424,8 +1424,9 @@ void StressTest::TestCompactFiles(ThreadState* /* thread */,
Status StressTest::TestBackupRestore( Status StressTest::TestBackupRestore(
ThreadState* thread, const std::vector<int>& rand_column_families, ThreadState* thread, const std::vector<int>& rand_column_families,
const std::vector<int64_t>& rand_keys) { const std::vector<int64_t>& rand_keys) {
std::string backup_dir = FLAGS_db + "/.backup" + ToString(thread->tid); std::string backup_dir = FLAGS_db + "/.backup" + std::to_string(thread->tid);
std::string restore_dir = FLAGS_db + "/.restore" + ToString(thread->tid); std::string restore_dir =
FLAGS_db + "/.restore" + std::to_string(thread->tid);
BackupEngineOptions backup_opts(backup_dir); BackupEngineOptions backup_opts(backup_dir);
// For debugging, get info_log from live options // For debugging, get info_log from live options
backup_opts.info_log = db_->GetDBOptions().info_log.get(); backup_opts.info_log = db_->GetDBOptions().info_log.get();
@ -1717,7 +1718,7 @@ Status StressTest::TestCheckpoint(ThreadState* thread,
const std::vector<int>& rand_column_families, const std::vector<int>& rand_column_families,
const std::vector<int64_t>& rand_keys) { const std::vector<int64_t>& rand_keys) {
std::string checkpoint_dir = std::string checkpoint_dir =
FLAGS_db + "/.checkpoint" + ToString(thread->tid); FLAGS_db + "/.checkpoint" + std::to_string(thread->tid);
Options tmp_opts(options_); Options tmp_opts(options_);
tmp_opts.listeners.clear(); tmp_opts.listeners.clear();
tmp_opts.env = db_stress_env; tmp_opts.env = db_stress_env;
@ -2204,7 +2205,7 @@ void StressTest::PrintEnv() const {
(unsigned long)FLAGS_ops_per_thread); (unsigned long)FLAGS_ops_per_thread);
std::string ttl_state("unused"); std::string ttl_state("unused");
if (FLAGS_ttl > 0) { if (FLAGS_ttl > 0) {
ttl_state = ToString(FLAGS_ttl); ttl_state = std::to_string(FLAGS_ttl);
} }
fprintf(stdout, "Time to live(sec) : %s\n", ttl_state.c_str()); fprintf(stdout, "Time to live(sec) : %s\n", ttl_state.c_str());
fprintf(stdout, "Read percentage : %d%%\n", FLAGS_readpercent); fprintf(stdout, "Read percentage : %d%%\n", FLAGS_readpercent);
@ -2608,7 +2609,7 @@ void StressTest::Open(SharedState* shared) {
cf_descriptors.emplace_back(name, ColumnFamilyOptions(options_)); cf_descriptors.emplace_back(name, ColumnFamilyOptions(options_));
} }
while (cf_descriptors.size() < (size_t)FLAGS_column_families) { while (cf_descriptors.size() < (size_t)FLAGS_column_families) {
std::string name = ToString(new_column_family_name_.load()); std::string name = std::to_string(new_column_family_name_.load());
new_column_family_name_++; new_column_family_name_++;
cf_descriptors.emplace_back(name, ColumnFamilyOptions(options_)); cf_descriptors.emplace_back(name, ColumnFamilyOptions(options_));
column_family_names_.push_back(name); column_family_names_.push_back(name);

View File

@ -187,8 +187,8 @@ Status FileExpectedStateManager::Open() {
// Check if crash happened after creating state file but before creating // Check if crash happened after creating state file but before creating
// trace file. // trace file.
if (saved_seqno_ != kMaxSequenceNumber) { if (saved_seqno_ != kMaxSequenceNumber) {
std::string saved_seqno_trace_path = std::string saved_seqno_trace_path = GetPathForFilename(
GetPathForFilename(ToString(saved_seqno_) + kTraceFilenameSuffix); std::to_string(saved_seqno_) + kTraceFilenameSuffix);
Status exists_status = Env::Default()->FileExists(saved_seqno_trace_path); Status exists_status = Env::Default()->FileExists(saved_seqno_trace_path);
if (exists_status.ok()) { if (exists_status.ok()) {
found_trace = true; found_trace = true;
@ -205,7 +205,7 @@ Status FileExpectedStateManager::Open() {
std::unique_ptr<WritableFile> wfile; std::unique_ptr<WritableFile> wfile;
const EnvOptions soptions; const EnvOptions soptions;
std::string saved_seqno_trace_path = std::string saved_seqno_trace_path =
GetPathForFilename(ToString(saved_seqno_) + kTraceFilenameSuffix); GetPathForFilename(std::to_string(saved_seqno_) + kTraceFilenameSuffix);
s = Env::Default()->NewWritableFile(saved_seqno_trace_path, &wfile, s = Env::Default()->NewWritableFile(saved_seqno_trace_path, &wfile,
soptions); soptions);
} }
@ -257,14 +257,14 @@ Status FileExpectedStateManager::Open() {
Status FileExpectedStateManager::SaveAtAndAfter(DB* db) { Status FileExpectedStateManager::SaveAtAndAfter(DB* db) {
SequenceNumber seqno = db->GetLatestSequenceNumber(); SequenceNumber seqno = db->GetLatestSequenceNumber();
std::string state_filename = ToString(seqno) + kStateFilenameSuffix; std::string state_filename = std::to_string(seqno) + kStateFilenameSuffix;
std::string state_file_temp_path = GetTempPathForFilename(state_filename); std::string state_file_temp_path = GetTempPathForFilename(state_filename);
std::string state_file_path = GetPathForFilename(state_filename); std::string state_file_path = GetPathForFilename(state_filename);
std::string latest_file_path = std::string latest_file_path =
GetPathForFilename(kLatestBasename + kStateFilenameSuffix); GetPathForFilename(kLatestBasename + kStateFilenameSuffix);
std::string trace_filename = ToString(seqno) + kTraceFilenameSuffix; std::string trace_filename = std::to_string(seqno) + kTraceFilenameSuffix;
std::string trace_file_path = GetPathForFilename(trace_filename); std::string trace_file_path = GetPathForFilename(trace_filename);
// Populate a tempfile and then rename it to atomically create "<seqno>.state" // Populate a tempfile and then rename it to atomically create "<seqno>.state"
@ -311,13 +311,13 @@ Status FileExpectedStateManager::SaveAtAndAfter(DB* db) {
// again, even if we crash. // again, even if we crash.
if (s.ok() && old_saved_seqno != kMaxSequenceNumber && if (s.ok() && old_saved_seqno != kMaxSequenceNumber &&
old_saved_seqno != saved_seqno_) { old_saved_seqno != saved_seqno_) {
s = Env::Default()->DeleteFile( s = Env::Default()->DeleteFile(GetPathForFilename(
GetPathForFilename(ToString(old_saved_seqno) + kStateFilenameSuffix)); std::to_string(old_saved_seqno) + kStateFilenameSuffix));
} }
if (s.ok() && old_saved_seqno != kMaxSequenceNumber && if (s.ok() && old_saved_seqno != kMaxSequenceNumber &&
old_saved_seqno != saved_seqno_) { old_saved_seqno != saved_seqno_) {
s = Env::Default()->DeleteFile( s = Env::Default()->DeleteFile(GetPathForFilename(
GetPathForFilename(ToString(old_saved_seqno) + kTraceFilenameSuffix)); std::to_string(old_saved_seqno) + kTraceFilenameSuffix));
} }
return s; return s;
} }
@ -461,7 +461,8 @@ Status FileExpectedStateManager::Restore(DB* db) {
return Status::Corruption("DB is older than any restorable expected state"); return Status::Corruption("DB is older than any restorable expected state");
} }
std::string state_filename = ToString(saved_seqno_) + kStateFilenameSuffix; std::string state_filename =
std::to_string(saved_seqno_) + kStateFilenameSuffix;
std::string state_file_path = GetPathForFilename(state_filename); std::string state_file_path = GetPathForFilename(state_filename);
std::string latest_file_temp_path = std::string latest_file_temp_path =
@ -469,7 +470,8 @@ Status FileExpectedStateManager::Restore(DB* db) {
std::string latest_file_path = std::string latest_file_path =
GetPathForFilename(kLatestBasename + kStateFilenameSuffix); GetPathForFilename(kLatestBasename + kStateFilenameSuffix);
std::string trace_filename = ToString(saved_seqno_) + kTraceFilenameSuffix; std::string trace_filename =
std::to_string(saved_seqno_) + kTraceFilenameSuffix;
std::string trace_file_path = GetPathForFilename(trace_filename); std::string trace_file_path = GetPathForFilename(trace_filename);
std::unique_ptr<TraceReader> trace_reader; std::unique_ptr<TraceReader> trace_reader;

View File

@ -189,7 +189,8 @@ class NonBatchedOpsStressTest : public StressTest {
if (thread->rand.OneInOpt(FLAGS_clear_column_family_one_in)) { if (thread->rand.OneInOpt(FLAGS_clear_column_family_one_in)) {
// drop column family and then create it again (can't drop default) // drop column family and then create it again (can't drop default)
int cf = thread->rand.Next() % (FLAGS_column_families - 1) + 1; int cf = thread->rand.Next() % (FLAGS_column_families - 1) + 1;
std::string new_name = ToString(new_column_family_name_.fetch_add(1)); std::string new_name =
std::to_string(new_column_family_name_.fetch_add(1));
{ {
MutexLock l(thread->shared->GetMutex()); MutexLock l(thread->shared->GetMutex());
fprintf( fprintf(
@ -789,7 +790,7 @@ class NonBatchedOpsStressTest : public StressTest {
const std::vector<int64_t>& rand_keys, const std::vector<int64_t>& rand_keys,
std::unique_ptr<MutexLock>& lock) override { std::unique_ptr<MutexLock>& lock) override {
const std::string sst_filename = const std::string sst_filename =
FLAGS_db + "/." + ToString(thread->tid) + ".sst"; FLAGS_db + "/." + std::to_string(thread->tid) + ".sst";
Status s; Status s;
if (db_stress_env->FileExists(sst_filename).ok()) { if (db_stress_env->FileExists(sst_filename).ok()) {
// Maybe we terminated abnormally before, so cleanup to give this file // Maybe we terminated abnormally before, so cleanup to give this file

2
env/env_test.cc vendored
View File

@ -1153,7 +1153,7 @@ TEST_P(EnvPosixTestWithParam, RandomAccessUniqueIDConcurrent) {
IoctlFriendlyTmpdir ift; IoctlFriendlyTmpdir ift;
std::vector<std::string> fnames; std::vector<std::string> fnames;
for (int i = 0; i < 1000; ++i) { for (int i = 0; i < 1000; ++i) {
fnames.push_back(ift.name() + "/" + "testfile" + ToString(i)); fnames.push_back(ift.name() + "/" + "testfile" + std::to_string(i));
// Create file. // Create file.
std::unique_ptr<WritableFile> wfile; std::unique_ptr<WritableFile> wfile;

10
env/fs_posix.cc vendored
View File

@ -606,8 +606,7 @@ class PosixFileSystem : public FileSystem {
return IOStatus::NotFound(); return IOStatus::NotFound();
default: default:
assert(err == EIO || err == ENOMEM); assert(err == EIO || err == ENOMEM);
return IOStatus::IOError("Unexpected error(" + return IOStatus::IOError("Unexpected error(" + std::to_string(err) +
ROCKSDB_NAMESPACE::ToString(err) +
") accessing file `" + fname + "' "); ") accessing file `" + fname + "' ");
} }
} }
@ -810,11 +809,10 @@ class PosixFileSystem : public FileSystem {
errno = ENOLCK; errno = ENOLCK;
// Note that the thread ID printed is the same one as the one in // Note that the thread ID printed is the same one as the one in
// posix logger, but posix logger prints it hex format. // posix logger, but posix logger prints it hex format.
return IOError( return IOError("lock hold by current process, acquire time " +
"lock hold by current process, acquire time " + std::to_string(prev_info.acquire_time) +
ROCKSDB_NAMESPACE::ToString(prev_info.acquire_time) +
" acquiring thread " + " acquiring thread " +
ROCKSDB_NAMESPACE::ToString(prev_info.acquiring_thread), std::to_string(prev_info.acquiring_thread),
fname, errno); fname, errno);
} }

66
env/io_posix.cc vendored
View File

@ -284,8 +284,8 @@ IOStatus PosixSequentialFile::PositionedRead(uint64_t offset, size_t n,
} }
if (r < 0) { if (r < 0) {
// An error: return a non-ok status // An error: return a non-ok status
s = IOError( s = IOError("While pread " + std::to_string(n) + " bytes from offset " +
"While pread " + ToString(n) + " bytes from offset " + ToString(offset), std::to_string(offset),
filename_, errno); filename_, errno);
} }
*result = Slice(scratch, (r < 0) ? 0 : n - left); *result = Slice(scratch, (r < 0) ? 0 : n - left);
@ -294,8 +294,8 @@ IOStatus PosixSequentialFile::PositionedRead(uint64_t offset, size_t n,
IOStatus PosixSequentialFile::Skip(uint64_t n) { IOStatus PosixSequentialFile::Skip(uint64_t n) {
if (fseek(file_, static_cast<long int>(n), SEEK_CUR)) { if (fseek(file_, static_cast<long int>(n), SEEK_CUR)) {
return IOError("While fseek to skip " + ToString(n) + " bytes", filename_, return IOError("While fseek to skip " + std::to_string(n) + " bytes",
errno); filename_, errno);
} }
return IOStatus::OK(); return IOStatus::OK();
} }
@ -310,8 +310,9 @@ IOStatus PosixSequentialFile::InvalidateCache(size_t offset, size_t length) {
// free OS pages // free OS pages
int ret = Fadvise(fd_, offset, length, POSIX_FADV_DONTNEED); int ret = Fadvise(fd_, offset, length, POSIX_FADV_DONTNEED);
if (ret != 0) { if (ret != 0) {
return IOError("While fadvise NotNeeded offset " + ToString(offset) + return IOError("While fadvise NotNeeded offset " +
" len " + ToString(length), std::to_string(offset) + " len " +
std::to_string(length),
filename_, errno); filename_, errno);
} }
} }
@ -596,8 +597,8 @@ IOStatus PosixRandomAccessFile::Read(uint64_t offset, size_t n,
} }
if (r < 0) { if (r < 0) {
// An error: return a non-ok status // An error: return a non-ok status
s = IOError( s = IOError("While pread offset " + std::to_string(offset) + " len " +
"While pread offset " + ToString(offset) + " len " + ToString(n), std::to_string(n),
filename_, errno); filename_, errno);
} }
*result = Slice(scratch, (r < 0) ? 0 : n - left); *result = Slice(scratch, (r < 0) ? 0 : n - left);
@ -704,8 +705,8 @@ IOStatus PosixRandomAccessFile::MultiRead(FSReadRequest* reqs,
} }
} }
return IOStatus::IOError("io_uring_submit_and_wait() requested " + return IOStatus::IOError("io_uring_submit_and_wait() requested " +
ToString(this_reqs) + " but returned " + std::to_string(this_reqs) + " but returned " +
ToString(ret)); std::to_string(ret));
} }
for (size_t i = 0; i < this_reqs; i++) { for (size_t i = 0; i < this_reqs; i++) {
@ -718,7 +719,8 @@ IOStatus PosixRandomAccessFile::MultiRead(FSReadRequest* reqs,
TEST_SYNC_POINT_CALLBACK( TEST_SYNC_POINT_CALLBACK(
"PosixRandomAccessFile::MultiRead:io_uring_wait_cqe:return", &ret); "PosixRandomAccessFile::MultiRead:io_uring_wait_cqe:return", &ret);
if (ret) { if (ret) {
ios = IOStatus::IOError("io_uring_wait_cqe() returns " + ToString(ret)); ios = IOStatus::IOError("io_uring_wait_cqe() returns " +
std::to_string(ret));
if (cqe != nullptr) { if (cqe != nullptr) {
io_uring_cqe_seen(iu, cqe); io_uring_cqe_seen(iu, cqe);
@ -738,7 +740,7 @@ IOStatus PosixRandomAccessFile::MultiRead(FSReadRequest* reqs,
req_wrap); req_wrap);
port::PrintStack(); port::PrintStack();
ios = IOStatus::IOError("io_uring_cqe_get_data() returned " + ios = IOStatus::IOError("io_uring_cqe_get_data() returned " +
ToString((uint64_t)req_wrap)); std::to_string((uint64_t)req_wrap));
continue; continue;
} }
wrap_cache.erase(wrap_check); wrap_cache.erase(wrap_check);
@ -801,8 +803,8 @@ IOStatus PosixRandomAccessFile::Prefetch(uint64_t offset, size_t n,
r = fcntl(fd_, F_RDADVISE, &advice); r = fcntl(fd_, F_RDADVISE, &advice);
#endif #endif
if (r == -1) { if (r == -1) {
s = IOError("While prefetching offset " + ToString(offset) + " len " + s = IOError("While prefetching offset " + std::to_string(offset) +
ToString(n), " len " + std::to_string(n),
filename_, errno); filename_, errno);
} }
} }
@ -855,8 +857,8 @@ IOStatus PosixRandomAccessFile::InvalidateCache(size_t offset, size_t length) {
if (ret == 0) { if (ret == 0) {
return IOStatus::OK(); return IOStatus::OK();
} }
return IOError("While fadvise NotNeeded offset " + ToString(offset) + return IOError("While fadvise NotNeeded offset " + std::to_string(offset) +
" len " + ToString(length), " len " + std::to_string(length),
filename_, errno); filename_, errno);
#endif #endif
} }
@ -922,7 +924,7 @@ IOStatus PosixRandomAccessFile::ReadAsync(
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "io_uring_submit error: %ld\n", long(ret)); fprintf(stderr, "io_uring_submit error: %ld\n", long(ret));
return IOStatus::IOError("io_uring_submit() requested but returned " + return IOStatus::IOError("io_uring_submit() requested but returned " +
ToString(ret)); std::to_string(ret));
} }
return IOStatus::OK(); return IOStatus::OK();
#else #else
@ -970,8 +972,8 @@ IOStatus PosixMmapReadableFile::Read(uint64_t offset, size_t n,
IOStatus s; IOStatus s;
if (offset > length_) { if (offset > length_) {
*result = Slice(); *result = Slice();
return IOError("While mmap read offset " + ToString(offset) + return IOError("While mmap read offset " + std::to_string(offset) +
" larger than file length " + ToString(length_), " larger than file length " + std::to_string(length_),
filename_, EINVAL); filename_, EINVAL);
} else if (offset + n > length_) { } else if (offset + n > length_) {
n = static_cast<size_t>(length_ - offset); n = static_cast<size_t>(length_ - offset);
@ -991,8 +993,8 @@ IOStatus PosixMmapReadableFile::InvalidateCache(size_t offset, size_t length) {
if (ret == 0) { if (ret == 0) {
return IOStatus::OK(); return IOStatus::OK();
} }
return IOError("While fadvise not needed. Offset " + ToString(offset) + return IOError("While fadvise not needed. Offset " + std::to_string(offset) +
" len" + ToString(length), " len" + std::to_string(length),
filename_, errno); filename_, errno);
#endif #endif
} }
@ -1244,8 +1246,8 @@ IOStatus PosixMmapFile::Allocate(uint64_t offset, uint64_t len,
if (alloc_status == 0) { if (alloc_status == 0) {
return IOStatus::OK(); return IOStatus::OK();
} else { } else {
return IOError( return IOError("While fallocate offset " + std::to_string(offset) +
"While fallocate offset " + ToString(offset) + " len " + ToString(len), " len " + std::to_string(len),
filename_, errno); filename_, errno);
} }
} }
@ -1311,7 +1313,7 @@ IOStatus PosixWritableFile::PositionedAppend(const Slice& data, uint64_t offset,
const char* src = data.data(); const char* src = data.data();
size_t nbytes = data.size(); size_t nbytes = data.size();
if (!PosixPositionedWrite(fd_, src, nbytes, static_cast<off_t>(offset))) { if (!PosixPositionedWrite(fd_, src, nbytes, static_cast<off_t>(offset))) {
return IOError("While pwrite to file at offset " + ToString(offset), return IOError("While pwrite to file at offset " + std::to_string(offset),
filename_, errno); filename_, errno);
} }
filesize_ = offset + nbytes; filesize_ = offset + nbytes;
@ -1323,8 +1325,8 @@ IOStatus PosixWritableFile::Truncate(uint64_t size, const IOOptions& /*opts*/,
IOStatus s; IOStatus s;
int r = ftruncate(fd_, size); int r = ftruncate(fd_, size);
if (r < 0) { if (r < 0) {
s = IOError("While ftruncate file to size " + ToString(size), filename_, s = IOError("While ftruncate file to size " + std::to_string(size),
errno); filename_, errno);
} else { } else {
filesize_ = size; filesize_ = size;
} }
@ -1481,8 +1483,8 @@ IOStatus PosixWritableFile::Allocate(uint64_t offset, uint64_t len,
if (alloc_status == 0) { if (alloc_status == 0) {
return IOStatus::OK(); return IOStatus::OK();
} else { } else {
return IOError( return IOError("While fallocate offset " + std::to_string(offset) +
"While fallocate offset " + ToString(offset) + " len " + ToString(len), " len " + std::to_string(len),
filename_, errno); filename_, errno);
} }
} }
@ -1508,7 +1510,7 @@ IOStatus PosixWritableFile::RangeSync(uint64_t offset, uint64_t nbytes,
static_cast<off_t>(nbytes), SYNC_FILE_RANGE_WRITE); static_cast<off_t>(nbytes), SYNC_FILE_RANGE_WRITE);
} }
if (ret != 0) { if (ret != 0) {
return IOError("While sync_file_range returned " + ToString(ret), return IOError("While sync_file_range returned " + std::to_string(ret),
filename_, errno); filename_, errno);
} }
return IOStatus::OK(); return IOStatus::OK();
@ -1544,8 +1546,8 @@ IOStatus PosixRandomRWFile::Write(uint64_t offset, const Slice& data,
const char* src = data.data(); const char* src = data.data();
size_t nbytes = data.size(); size_t nbytes = data.size();
if (!PosixPositionedWrite(fd_, src, nbytes, static_cast<off_t>(offset))) { if (!PosixPositionedWrite(fd_, src, nbytes, static_cast<off_t>(offset))) {
return IOError( return IOError("While write random read/write file at offset " +
"While write random read/write file at offset " + ToString(offset), std::to_string(offset),
filename_, errno); filename_, errno);
} }
@ -1566,7 +1568,7 @@ IOStatus PosixRandomRWFile::Read(uint64_t offset, size_t n,
continue; continue;
} }
return IOError("While reading random read/write file offset " + return IOError("While reading random read/write file offset " +
ToString(offset) + " len " + ToString(n), std::to_string(offset) + " len " + std::to_string(n),
filename_, errno); filename_, errno);
} else if (done == 0) { } else if (done == 0) {
// Nothing more to read // Nothing more to read

View File

@ -30,7 +30,7 @@ class DeleteSchedulerTest : public testing::Test {
for (size_t i = 0; i < kNumDataDirs; ++i) { for (size_t i = 0; i < kNumDataDirs; ++i) {
dummy_files_dirs_.emplace_back( dummy_files_dirs_.emplace_back(
test::PerThreadDBPath(env_, "delete_scheduler_dummy_data_dir") + test::PerThreadDBPath(env_, "delete_scheduler_dummy_data_dir") +
ToString(i)); std::to_string(i));
DestroyAndCreateDir(dummy_files_dirs_.back()); DestroyAndCreateDir(dummy_files_dirs_.back());
} }
stats_ = ROCKSDB_NAMESPACE::CreateDBStatistics(); stats_ = ROCKSDB_NAMESPACE::CreateDBStatistics();
@ -153,7 +153,7 @@ TEST_F(DeleteSchedulerTest, BasicRateLimiting) {
// Create 100 dummy files, every file is 1 Kb // Create 100 dummy files, every file is 1 Kb
std::vector<std::string> generated_files; std::vector<std::string> generated_files;
for (int i = 0; i < num_files; i++) { for (int i = 0; i < num_files; i++) {
std::string file_name = "file" + ToString(i) + ".data"; std::string file_name = "file" + std::to_string(i) + ".data";
generated_files.push_back(NewDummyFile(file_name, file_size)); generated_files.push_back(NewDummyFile(file_name, file_size));
} }
@ -265,7 +265,7 @@ TEST_F(DeleteSchedulerTest, RateLimitingMultiThreaded) {
// Create 100 dummy files, every file is 1 Kb // Create 100 dummy files, every file is 1 Kb
std::vector<std::string> generated_files; std::vector<std::string> generated_files;
for (int i = 0; i < num_files * thread_cnt; i++) { for (int i = 0; i < num_files * thread_cnt; i++) {
std::string file_name = "file" + ToString(i) + ".data"; std::string file_name = "file" + std::to_string(i) + ".data";
generated_files.push_back(NewDummyFile(file_name, file_size)); generated_files.push_back(NewDummyFile(file_name, file_size));
} }
@ -405,7 +405,7 @@ TEST_F(DeleteSchedulerTest, BackgroundError) {
// Generate 10 dummy files and move them to trash // Generate 10 dummy files and move them to trash
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
std::string file_name = "data_" + ToString(i) + ".data"; std::string file_name = "data_" + std::to_string(i) + ".data";
ASSERT_OK(delete_scheduler_->DeleteFile(NewDummyFile(file_name), "")); ASSERT_OK(delete_scheduler_->DeleteFile(NewDummyFile(file_name), ""));
} }
ASSERT_EQ(CountNormalFiles(), 0); ASSERT_EQ(CountNormalFiles(), 0);
@ -415,7 +415,7 @@ TEST_F(DeleteSchedulerTest, BackgroundError) {
// BackgroundEmptyTrash since we already deleted the files it was // BackgroundEmptyTrash since we already deleted the files it was
// goind to delete // goind to delete
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
std::string file_name = "data_" + ToString(i) + ".data.trash"; std::string file_name = "data_" + std::to_string(i) + ".data.trash";
ASSERT_OK(env_->DeleteFile(dummy_files_dirs_[0] + "/" + file_name)); ASSERT_OK(env_->DeleteFile(dummy_files_dirs_[0] + "/" + file_name));
} }
@ -455,7 +455,7 @@ TEST_F(DeleteSchedulerTest, StartBGEmptyTrashMultipleTimes) {
for (int run = 1; run <= 5; run++) { for (int run = 1; run <= 5; run++) {
// Generate kTestFileNum dummy files and move them to trash // Generate kTestFileNum dummy files and move them to trash
for (int i = 0; i < kTestFileNum; i++) { for (int i = 0; i < kTestFileNum; i++) {
std::string file_name = "data_" + ToString(i) + ".data"; std::string file_name = "data_" + std::to_string(i) + ".data";
ASSERT_OK(delete_scheduler_->DeleteFile(NewDummyFile(file_name), "")); ASSERT_OK(delete_scheduler_->DeleteFile(NewDummyFile(file_name), ""));
} }
ASSERT_EQ(CountNormalFiles(), 0); ASSERT_EQ(CountNormalFiles(), 0);
@ -555,7 +555,7 @@ TEST_F(DeleteSchedulerTest, DestructorWithNonEmptyQueue) {
NewDeleteScheduler(); NewDeleteScheduler();
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
std::string file_name = "data_" + ToString(i) + ".data"; std::string file_name = "data_" + std::to_string(i) + ".data";
ASSERT_OK(delete_scheduler_->DeleteFile(NewDummyFile(file_name), "")); ASSERT_OK(delete_scheduler_->DeleteFile(NewDummyFile(file_name), ""));
} }
@ -610,7 +610,7 @@ TEST_F(DeleteSchedulerTest, DISABLED_DynamicRateLimiting1) {
// Create 100 dummy files, every file is 1 Kb // Create 100 dummy files, every file is 1 Kb
std::vector<std::string> generated_files; std::vector<std::string> generated_files;
for (int i = 0; i < num_files; i++) { for (int i = 0; i < num_files; i++) {
std::string file_name = "file" + ToString(i) + ".data"; std::string file_name = "file" + std::to_string(i) + ".data";
generated_files.push_back(NewDummyFile(file_name, file_size)); generated_files.push_back(NewDummyFile(file_name, file_size));
} }
@ -671,7 +671,7 @@ TEST_F(DeleteSchedulerTest, ImmediateDeleteOn25PercDBSize) {
std::vector<std::string> generated_files; std::vector<std::string> generated_files;
for (int i = 0; i < num_files; i++) { for (int i = 0; i < num_files; i++) {
std::string file_name = "file" + ToString(i) + ".data"; std::string file_name = "file" + std::to_string(i) + ".data";
generated_files.push_back(NewDummyFile(file_name, file_size)); generated_files.push_back(NewDummyFile(file_name, file_size));
} }

View File

@ -119,7 +119,7 @@ jbyteArray Java_org_rocksdb_WriteBatchTest_getContents(JNIEnv* env,
break; break;
} }
state.append("@"); state.append("@");
state.append(ROCKSDB_NAMESPACE::ToString(ikey.sequence)); state.append(std::to_string(ikey.sequence));
} }
if (!s.ok()) { if (!s.ok()) {
state.append(s.ToString()); state.append(s.ToString());

View File

@ -114,19 +114,18 @@ Status JemallocNodumpAllocator::InitializeArenas() {
mallctl("arenas.create", &arena_index_, &arena_index_size, nullptr, 0); mallctl("arenas.create", &arena_index_, &arena_index_size, nullptr, 0);
if (ret != 0) { if (ret != 0) {
return Status::Incomplete("Failed to create jemalloc arena, error code: " + return Status::Incomplete("Failed to create jemalloc arena, error code: " +
ROCKSDB_NAMESPACE::ToString(ret)); std::to_string(ret));
} }
assert(arena_index_ != 0); assert(arena_index_ != 0);
// Read existing hooks. // Read existing hooks.
std::string key = std::string key = "arena." + std::to_string(arena_index_) + ".extent_hooks";
"arena." + ROCKSDB_NAMESPACE::ToString(arena_index_) + ".extent_hooks";
extent_hooks_t* hooks; extent_hooks_t* hooks;
size_t hooks_size = sizeof(hooks); size_t hooks_size = sizeof(hooks);
ret = mallctl(key.c_str(), &hooks, &hooks_size, nullptr, 0); ret = mallctl(key.c_str(), &hooks, &hooks_size, nullptr, 0);
if (ret != 0) { if (ret != 0) {
return Status::Incomplete("Failed to read existing hooks, error code: " + return Status::Incomplete("Failed to read existing hooks, error code: " +
ROCKSDB_NAMESPACE::ToString(ret)); std::to_string(ret));
} }
// Store existing alloc. // Store existing alloc.
@ -146,7 +145,7 @@ Status JemallocNodumpAllocator::InitializeArenas() {
ret = mallctl(key.c_str(), nullptr, nullptr, &hooks_ptr, sizeof(hooks_ptr)); ret = mallctl(key.c_str(), nullptr, nullptr, &hooks_ptr, sizeof(hooks_ptr));
if (ret != 0) { if (ret != 0) {
return Status::Incomplete("Failed to set custom hook, error code: " + return Status::Incomplete("Failed to set custom hook, error code: " +
ROCKSDB_NAMESPACE::ToString(ret)); std::to_string(ret));
} }
return Status::OK(); return Status::OK();
} }
@ -226,12 +225,11 @@ void* JemallocNodumpAllocator::Alloc(extent_hooks_t* extent, void* new_addr,
Status JemallocNodumpAllocator::DestroyArena(unsigned arena_index) { Status JemallocNodumpAllocator::DestroyArena(unsigned arena_index) {
assert(arena_index != 0); assert(arena_index != 0);
std::string key = std::string key = "arena." + std::to_string(arena_index) + ".destroy";
"arena." + ROCKSDB_NAMESPACE::ToString(arena_index) + ".destroy";
int ret = mallctl(key.c_str(), nullptr, 0, nullptr, 0); int ret = mallctl(key.c_str(), nullptr, 0, nullptr, 0);
if (ret != 0) { if (ret != 0) {
return Status::Incomplete("Failed to destroy jemalloc arena, error code: " + return Status::Incomplete("Failed to destroy jemalloc arena, error code: " +
ROCKSDB_NAMESPACE::ToString(ret)); std::to_string(ret));
} }
return Status::OK(); return Status::OK();
} }

View File

@ -353,7 +353,7 @@ SkipListFactory::SkipListFactory(size_t lookahead) : lookahead_(lookahead) {
std::string SkipListFactory::GetId() const { std::string SkipListFactory::GetId() const {
std::string id = Name(); std::string id = Name();
if (lookahead_ > 0) { if (lookahead_ > 0) {
id.append(":").append(ROCKSDB_NAMESPACE::ToString(lookahead_)); id.append(":").append(std::to_string(lookahead_));
} }
return id; return id;
} }

View File

@ -1342,7 +1342,7 @@ static void RandomAccessFileReaderRead(benchmark::State& state) {
auto statistics_share = CreateDBStatistics(); auto statistics_share = CreateDBStatistics();
Statistics* statistics = enable_statistics ? statistics_share.get() : nullptr; Statistics* statistics = enable_statistics ? statistics_share.get() : nullptr;
for (int i = 0; i < kFileNum; i++) { for (int i = 0; i < kFileNum; i++) {
std::string fname = fname_base + ToString(i); std::string fname = fname_base + std::to_string(i);
std::string content = rand.RandomString(kDefaultPageSize); std::string content = rand.RandomString(kDefaultPageSize);
std::unique_ptr<WritableFile> tgt_file; std::unique_ptr<WritableFile> tgt_file;
env->NewWritableFile(fname, &tgt_file, EnvOptions()); env->NewWritableFile(fname, &tgt_file, EnvOptions());
@ -1375,7 +1375,7 @@ static void RandomAccessFileReaderRead(benchmark::State& state) {
// clean up // clean up
for (int i = 0; i < kFileNum; i++) { for (int i = 0; i < kFileNum; i++) {
std::string fname = fname_base + ToString(i); std::string fname = fname_base + std::to_string(i);
env->DeleteFile(fname); // ignore return, okay to fail cleanup env->DeleteFile(fname); // ignore return, okay to fail cleanup
} }
} }

View File

@ -173,7 +173,7 @@ TEST_F(ConfigurableTest, GetOptionsTest) {
int i = 11; int i = 11;
for (auto opt : {"", "shared.", "unique.", "pointer."}) { for (auto opt : {"", "shared.", "unique.", "pointer."}) {
std::string value; std::string value;
std::string expected = ToString(i); std::string expected = std::to_string(i);
std::string opt_name = opt; std::string opt_name = opt;
ASSERT_OK( ASSERT_OK(
simple->ConfigureOption(config_options_, opt_name + "int", expected)); simple->ConfigureOption(config_options_, opt_name + "int", expected));

View File

@ -463,43 +463,43 @@ bool SerializeSingleOptionHelper(const void* opt_address,
*value = *(static_cast<const bool*>(opt_address)) ? "true" : "false"; *value = *(static_cast<const bool*>(opt_address)) ? "true" : "false";
break; break;
case OptionType::kInt: case OptionType::kInt:
*value = ToString(*(static_cast<const int*>(opt_address))); *value = std::to_string(*(static_cast<const int*>(opt_address)));
break; break;
case OptionType::kInt32T: case OptionType::kInt32T:
*value = ToString(*(static_cast<const int32_t*>(opt_address))); *value = std::to_string(*(static_cast<const int32_t*>(opt_address)));
break; break;
case OptionType::kInt64T: case OptionType::kInt64T:
{ {
int64_t v; int64_t v;
GetUnaligned(static_cast<const int64_t*>(opt_address), &v); GetUnaligned(static_cast<const int64_t*>(opt_address), &v);
*value = ToString(v); *value = std::to_string(v);
} }
break; break;
case OptionType::kUInt: case OptionType::kUInt:
*value = ToString(*(static_cast<const unsigned int*>(opt_address))); *value = std::to_string(*(static_cast<const unsigned int*>(opt_address)));
break; break;
case OptionType::kUInt8T: case OptionType::kUInt8T:
*value = ToString(*(static_cast<const uint8_t*>(opt_address))); *value = std::to_string(*(static_cast<const uint8_t*>(opt_address)));
break; break;
case OptionType::kUInt32T: case OptionType::kUInt32T:
*value = ToString(*(static_cast<const uint32_t*>(opt_address))); *value = std::to_string(*(static_cast<const uint32_t*>(opt_address)));
break; break;
case OptionType::kUInt64T: case OptionType::kUInt64T:
{ {
uint64_t v; uint64_t v;
GetUnaligned(static_cast<const uint64_t*>(opt_address), &v); GetUnaligned(static_cast<const uint64_t*>(opt_address), &v);
*value = ToString(v); *value = std::to_string(v);
} }
break; break;
case OptionType::kSizeT: case OptionType::kSizeT:
{ {
size_t v; size_t v;
GetUnaligned(static_cast<const size_t*>(opt_address), &v); GetUnaligned(static_cast<const size_t*>(opt_address), &v);
*value = ToString(v); *value = std::to_string(v);
} }
break; break;
case OptionType::kDouble: case OptionType::kDouble:
*value = ToString(*(static_cast<const double*>(opt_address))); *value = std::to_string(*(static_cast<const double*>(opt_address)));
break; break;
case OptionType::kString: case OptionType::kString:
*value = *value =

View File

@ -79,16 +79,16 @@ Status PersistRocksDBOptions(const ConfigOptions& config_options_in,
std::string options_file_content; std::string options_file_content;
s = writable->Append(option_file_header + "[" + s = writable->Append(
opt_section_titles[kOptionSectionVersion] + option_file_header + "[" + opt_section_titles[kOptionSectionVersion] +
"]\n" "]\n"
" rocksdb_version=" + " rocksdb_version=" +
ToString(ROCKSDB_MAJOR) + "." + ToString(ROCKSDB_MINOR) + std::to_string(ROCKSDB_MAJOR) + "." + std::to_string(ROCKSDB_MINOR) +
"." + ToString(ROCKSDB_PATCH) + "\n"); "." + std::to_string(ROCKSDB_PATCH) + "\n");
if (s.ok()) { if (s.ok()) {
s = writable->Append( s = writable->Append(
" options_file_version=" + ToString(ROCKSDB_OPTION_FILE_MAJOR) + "." + " options_file_version=" + std::to_string(ROCKSDB_OPTION_FILE_MAJOR) +
ToString(ROCKSDB_OPTION_FILE_MINOR) + "\n"); "." + std::to_string(ROCKSDB_OPTION_FILE_MINOR) + "\n");
} }
if (s.ok()) { if (s.ok()) {
s = writable->Append("\n[" + opt_section_titles[kOptionSectionDBOptions] + s = writable->Append("\n[" + opt_section_titles[kOptionSectionDBOptions] +
@ -216,7 +216,7 @@ Status RocksDBOptionsParser::InvalidArgument(const int line_num,
const std::string& message) { const std::string& message) {
return Status::InvalidArgument( return Status::InvalidArgument(
"[RocksDBOptionsParser Error] ", "[RocksDBOptionsParser Error] ",
message + " (at line " + ToString(line_num) + ")"); message + " (at line " + std::to_string(line_num) + ")");
} }
Status RocksDBOptionsParser::ParseStatement(std::string* name, Status RocksDBOptionsParser::ParseStatement(std::string* name,
@ -590,7 +590,7 @@ Status RocksDBOptionsParser::VerifyRocksDBOptionsFromFile(
return Status::InvalidArgument( return Status::InvalidArgument(
"[RocksDBOptionParser Error] The persisted options and the db" "[RocksDBOptionParser Error] The persisted options and the db"
"instance does not have the same name for column family ", "instance does not have the same name for column family ",
ToString(i)); std::to_string(i));
} }
} }

View File

@ -3346,31 +3346,31 @@ TEST_F(OptionsParserTest, IgnoreUnknownOptions) {
if (case_id == 0) { if (case_id == 0) {
// same version // same version
should_ignore = false; should_ignore = false;
version_string = version_string = std::to_string(ROCKSDB_MAJOR) + "." +
ToString(ROCKSDB_MAJOR) + "." + ToString(ROCKSDB_MINOR) + ".0"; std::to_string(ROCKSDB_MINOR) + ".0";
} else if (case_id == 1) { } else if (case_id == 1) {
// higher minor version // higher minor version
should_ignore = true; should_ignore = true;
version_string = version_string = std::to_string(ROCKSDB_MAJOR) + "." +
ToString(ROCKSDB_MAJOR) + "." + ToString(ROCKSDB_MINOR + 1) + ".0"; std::to_string(ROCKSDB_MINOR + 1) + ".0";
} else if (case_id == 2) { } else if (case_id == 2) {
// higher major version. // higher major version.
should_ignore = true; should_ignore = true;
version_string = ToString(ROCKSDB_MAJOR + 1) + ".0.0"; version_string = std::to_string(ROCKSDB_MAJOR + 1) + ".0.0";
} else if (case_id == 3) { } else if (case_id == 3) {
// lower minor version // lower minor version
#if ROCKSDB_MINOR == 0 #if ROCKSDB_MINOR == 0
continue; continue;
#else #else
version_string = version_string = std::to_string(ROCKSDB_MAJOR) + "." +
ToString(ROCKSDB_MAJOR) + "." + ToString(ROCKSDB_MINOR - 1) + ".0"; std::to_string(ROCKSDB_MINOR - 1) + ".0";
should_ignore = false; should_ignore = false;
#endif #endif
} else { } else {
// lower major version // lower major version
should_ignore = false; should_ignore = false;
version_string = version_string = std::to_string(ROCKSDB_MAJOR - 1) + "." +
ToString(ROCKSDB_MAJOR - 1) + "." + ToString(ROCKSDB_MINOR) + ".0"; std::to_string(ROCKSDB_MINOR) + ".0";
} }
std::string options_file_content = std::string options_file_content =

View File

@ -51,7 +51,7 @@ void AppendItem(std::string* props, const std::string& key,
template <class TKey> template <class TKey>
void AppendItem(std::string* props, const TKey& key, const std::string& value) { void AppendItem(std::string* props, const TKey& key, const std::string& value) {
std::string key_str = ROCKSDB_NAMESPACE::ToString(key); std::string key_str = std::to_string(key);
AppendItem(props, key_str, value); AppendItem(props, key_str, value);
} }
} // namespace } // namespace
@ -337,7 +337,7 @@ std::string BlockBasedFilterBlockReader::ToString() const {
result.reserve(1024); result.reserve(1024);
std::string s_bo("Block offset"), s_hd("Hex dump"), s_fb("# filter blocks"); std::string s_bo("Block offset"), s_hd("Hex dump"), s_fb("# filter blocks");
AppendItem(&result, s_fb, ROCKSDB_NAMESPACE::ToString(num)); AppendItem(&result, s_fb, std::to_string(num));
AppendItem(&result, s_bo, s_hd); AppendItem(&result, s_bo, s_hd);
for (size_t index = 0; index < num; index++) { for (size_t index = 0; index < num; index++) {
@ -345,8 +345,7 @@ std::string BlockBasedFilterBlockReader::ToString() const {
uint32_t limit = DecodeFixed32(offset + index * 4 + 4); uint32_t limit = DecodeFixed32(offset + index * 4 + 4);
if (start != limit) { if (start != limit) {
result.append(" filter block # " + result.append(" filter block # " + std::to_string(index + 1) + "\n");
ROCKSDB_NAMESPACE::ToString(index + 1) + "\n");
Slice filter = Slice(data + start, limit - start); Slice filter = Slice(data + start, limit - start);
AppendItem(&result, start, filter.ToString(true)); AppendItem(&result, start, filter.ToString(true));
} }

View File

@ -686,8 +686,7 @@ Status BlockBasedTableFactory::ValidateOptions(
table_options_.checksum, &garbage)) { table_options_.checksum, &garbage)) {
return Status::InvalidArgument( return Status::InvalidArgument(
"Unrecognized ChecksumType for checksum: " + "Unrecognized ChecksumType for checksum: " +
ROCKSDB_NAMESPACE::ToString( std::to_string(static_cast<uint32_t>(table_options_.checksum)));
static_cast<uint32_t>(table_options_.checksum)));
} }
return TableFactory::ValidateOptions(db_opts, cf_opts); return TableFactory::ValidateOptions(db_opts, cf_opts);
} }

View File

@ -1811,10 +1811,11 @@ void BlockBasedTable::RetrieveMultipleBlocks(
if (s.ok()) { if (s.ok()) {
if ((req.result.size() != req.len) || if ((req.result.size() != req.len) ||
(req_offset + BlockSizeWithTrailer(handle) > req.result.size())) { (req_offset + BlockSizeWithTrailer(handle) > req.result.size())) {
s = Status::Corruption( s = Status::Corruption("truncated block read from " +
"truncated block read from " + rep_->file->file_name() + rep_->file->file_name() + " offset " +
" offset " + ToString(handle.offset()) + ", expected " + std::to_string(handle.offset()) + ", expected " +
ToString(req.len) + " bytes, got " + ToString(req.result.size())); std::to_string(req.len) + " bytes, got " +
std::to_string(req.result.size()));
} }
} }
@ -3236,7 +3237,7 @@ Status BlockBasedTable::CreateIndexReader(
} }
default: { default: {
std::string error_message = std::string error_message =
"Unrecognized index type: " + ToString(rep_->index_type); "Unrecognized index type: " + std::to_string(rep_->index_type);
return Status::InvalidArgument(error_message.c_str()); return Status::InvalidArgument(error_message.c_str());
} }
} }
@ -3659,8 +3660,8 @@ Status BlockBasedTable::DumpDataBlocks(std::ostream& out_stream) {
out_stream << " # data blocks: " << num_datablocks << "\n"; out_stream << " # data blocks: " << num_datablocks << "\n";
out_stream << " min data block size: " << datablock_size_min << "\n"; out_stream << " min data block size: " << datablock_size_min << "\n";
out_stream << " max data block size: " << datablock_size_max << "\n"; out_stream << " max data block size: " << datablock_size_max << "\n";
out_stream << " avg data block size: " << ToString(datablock_size_avg) out_stream << " avg data block size: "
<< "\n"; << std::to_string(datablock_size_avg) << "\n";
} }
return Status::OK(); return Status::OK();

View File

@ -1542,7 +1542,7 @@ BloomLikeFilterPolicy::GetStandard128RibbonBuilderWithContext(
} }
std::string BloomLikeFilterPolicy::GetBitsPerKeySuffix() const { std::string BloomLikeFilterPolicy::GetBitsPerKeySuffix() const {
std::string rv = ":" + ROCKSDB_NAMESPACE::ToString(millibits_per_key_ / 1000); std::string rv = ":" + std::to_string(millibits_per_key_ / 1000);
int frac = millibits_per_key_ % 1000; int frac = millibits_per_key_ % 1000;
if (frac > 0) { if (frac > 0) {
rv.push_back('.'); rv.push_back('.');
@ -1837,7 +1837,7 @@ const char* RibbonFilterPolicy::kNickName() { return "rocksdb.RibbonFilter"; }
std::string RibbonFilterPolicy::GetId() const { std::string RibbonFilterPolicy::GetId() const {
return BloomLikeFilterPolicy::GetId() + ":" + return BloomLikeFilterPolicy::GetId() + ":" +
ROCKSDB_NAMESPACE::ToString(bloom_before_level_); std::to_string(bloom_before_level_);
} }
const FilterPolicy* NewRibbonFilterPolicy(double bloom_equivalent_bits_per_key, const FilterPolicy* NewRibbonFilterPolicy(double bloom_equivalent_bits_per_key,

View File

@ -285,8 +285,8 @@ class HashIndexBuilder : public IndexBuilder {
} }
// need a hard copy otherwise the underlying data changes all the time. // need a hard copy otherwise the underlying data changes all the time.
// TODO(kailiu) ToString() is expensive. We may speed up can avoid data // TODO(kailiu) std::to_string() is expensive. We may speed up can avoid
// copy. // data copy.
pending_entry_prefix_ = key_prefix.ToString(); pending_entry_prefix_ = key_prefix.ToString();
pending_block_num_ = 1; pending_block_num_ = 1;
pending_entry_index_ = static_cast<uint32_t>(current_restart_index_); pending_entry_index_ = static_cast<uint32_t>(current_restart_index_);

View File

@ -43,10 +43,10 @@ Status VerifyBlockChecksum(ChecksumType type, const char* data,
computed = crc32c::Unmask(computed); computed = crc32c::Unmask(computed);
} }
return Status::Corruption( return Status::Corruption(
"block checksum mismatch: stored = " + ToString(stored) + "block checksum mismatch: stored = " + std::to_string(stored) +
", computed = " + ToString(computed) + ", type = " + ToString(type) + ", computed = " + std::to_string(computed) +
" in " + file_name + " offset " + ToString(offset) + " size " + ", type = " + std::to_string(type) + " in " + file_name + " offset " +
ToString(block_size)); std::to_string(offset) + " size " + std::to_string(block_size));
} }
} }
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View File

@ -305,11 +305,11 @@ IOStatus BlockFetcher::ReadBlockContents() {
} }
if (slice_.size() != block_size_with_trailer_) { if (slice_.size() != block_size_with_trailer_) {
return IOStatus::Corruption("truncated block read from " + return IOStatus::Corruption(
file_->file_name() + " offset " + "truncated block read from " + file_->file_name() + " offset " +
ToString(handle_.offset()) + ", expected " + std::to_string(handle_.offset()) + ", expected " +
ToString(block_size_with_trailer_) + std::to_string(block_size_with_trailer_) + " bytes, got " +
" bytes, got " + ToString(slice_.size())); std::to_string(slice_.size()));
} }
ProcessTrailerIfPresent(); ProcessTrailerIfPresent();

View File

@ -103,7 +103,7 @@ void CuckooTableBuilder::Add(const Slice& key, const Slice& value) {
} }
if (ikey.type != kTypeDeletion && ikey.type != kTypeValue) { if (ikey.type != kTypeDeletion && ikey.type != kTypeValue) {
status_ = Status::NotSupported("Unsupported key type " + status_ = Status::NotSupported("Unsupported key type " +
ToString(ikey.type)); std::to_string(ikey.type));
return; return;
} }

View File

@ -400,7 +400,7 @@ std::string GetFileName(uint64_t num) {
FLAGS_file_dir = test::TmpDir(); FLAGS_file_dir = test::TmpDir();
} }
return test::PerThreadDBPath(FLAGS_file_dir, "cuckoo_read_benchmark") + return test::PerThreadDBPath(FLAGS_file_dir, "cuckoo_read_benchmark") +
ToString(num / 1000000) + "Mkeys"; std::to_string(num / 1000000) + "Mkeys";
} }
// Create last level file as we are interested in measuring performance of // Create last level file as we are interested in measuring performance of

View File

@ -295,7 +295,7 @@ Status Footer::DecodeFrom(Slice input, uint64_t input_offset) {
format_version_ = DecodeFixed32(part3_ptr); format_version_ = DecodeFixed32(part3_ptr);
if (!IsSupportedFormatVersion(format_version_)) { if (!IsSupportedFormatVersion(format_version_)) {
return Status::Corruption("Corrupt or unsupported format_version: " + return Status::Corruption("Corrupt or unsupported format_version: " +
ROCKSDB_NAMESPACE::ToString(format_version_)); std::to_string(format_version_));
} }
// All known format versions >= 1 occupy exactly this many bytes. // All known format versions >= 1 occupy exactly this many bytes.
if (input.size() < kNewVersionsEncodedLength) { if (input.size() < kNewVersionsEncodedLength) {
@ -308,9 +308,8 @@ Status Footer::DecodeFrom(Slice input, uint64_t input_offset) {
char chksum = input.data()[0]; char chksum = input.data()[0];
checksum_type_ = lossless_cast<ChecksumType>(chksum); checksum_type_ = lossless_cast<ChecksumType>(chksum);
if (!IsSupportedChecksumType(checksum_type())) { if (!IsSupportedChecksumType(checksum_type())) {
return Status::Corruption( return Status::Corruption("Corrupt or unsupported checksum type: " +
"Corrupt or unsupported checksum type: " + std::to_string(lossless_cast<uint8_t>(chksum)));
ROCKSDB_NAMESPACE::ToString(lossless_cast<uint8_t>(chksum)));
} }
// Consume checksum type field // Consume checksum type field
input.remove_prefix(1); input.remove_prefix(1);
@ -333,15 +332,15 @@ std::string Footer::ToString() const {
if (legacy) { if (legacy) {
result.append("metaindex handle: " + metaindex_handle_.ToString() + "\n "); result.append("metaindex handle: " + metaindex_handle_.ToString() + "\n ");
result.append("index handle: " + index_handle_.ToString() + "\n "); result.append("index handle: " + index_handle_.ToString() + "\n ");
result.append("table_magic_number: " + result.append("table_magic_number: " + std::to_string(table_magic_number_) +
ROCKSDB_NAMESPACE::ToString(table_magic_number_) + "\n "); "\n ");
} else { } else {
result.append("metaindex handle: " + metaindex_handle_.ToString() + "\n "); result.append("metaindex handle: " + metaindex_handle_.ToString() + "\n ");
result.append("index handle: " + index_handle_.ToString() + "\n "); result.append("index handle: " + index_handle_.ToString() + "\n ");
result.append("table_magic_number: " + result.append("table_magic_number: " + std::to_string(table_magic_number_) +
ROCKSDB_NAMESPACE::ToString(table_magic_number_) + "\n "); "\n ");
result.append("format version: " + result.append("format version: " + std::to_string(format_version_) +
ROCKSDB_NAMESPACE::ToString(format_version_) + "\n "); "\n ");
} }
return result; return result;
} }
@ -351,7 +350,8 @@ Status ReadFooterFromFile(const IOOptions& opts, RandomAccessFileReader* file,
uint64_t file_size, Footer* footer, uint64_t file_size, Footer* footer,
uint64_t enforce_table_magic_number) { uint64_t enforce_table_magic_number) {
if (file_size < Footer::kMinEncodedLength) { if (file_size < Footer::kMinEncodedLength) {
return Status::Corruption("file is too short (" + ToString(file_size) + return Status::Corruption("file is too short (" +
std::to_string(file_size) +
" bytes) to be an " " bytes) to be an "
"sstable: " + "sstable: " +
file->file_name()); file->file_name());
@ -390,7 +390,8 @@ Status ReadFooterFromFile(const IOOptions& opts, RandomAccessFileReader* file,
// Check that we actually read the whole footer from the file. It may be // Check that we actually read the whole footer from the file. It may be
// that size isn't correct. // that size isn't correct.
if (footer_input.size() < Footer::kMinEncodedLength) { if (footer_input.size() < Footer::kMinEncodedLength) {
return Status::Corruption("file is too short (" + ToString(file_size) + return Status::Corruption("file is too short (" +
std::to_string(file_size) +
" bytes) to be an " " bytes) to be an "
"sstable" + "sstable" +
file->file_name()); file->file_name());
@ -402,10 +403,11 @@ Status ReadFooterFromFile(const IOOptions& opts, RandomAccessFileReader* file,
} }
if (enforce_table_magic_number != 0 && if (enforce_table_magic_number != 0 &&
enforce_table_magic_number != footer->table_magic_number()) { enforce_table_magic_number != footer->table_magic_number()) {
return Status::Corruption( return Status::Corruption("Bad table magic number: expected " +
"Bad table magic number: expected " + std::to_string(enforce_table_magic_number) +
ToString(enforce_table_magic_number) + ", found " + ", found " +
ToString(footer->table_magic_number()) + " in " + file->file_name()); std::to_string(footer->table_magic_number()) +
" in " + file->file_name());
} }
return Status::OK(); return Status::OK();
} }

View File

@ -416,14 +416,14 @@ Status PlainTableReader::PopulateIndex(TableProperties* props,
// Fill two table properties. // Fill two table properties.
if (!index_in_file) { if (!index_in_file) {
props->user_collected_properties["plain_table_hash_table_size"] = props->user_collected_properties["plain_table_hash_table_size"] =
ToString(index_.GetIndexSize() * PlainTableIndex::kOffsetLen); std::to_string(index_.GetIndexSize() * PlainTableIndex::kOffsetLen);
props->user_collected_properties["plain_table_sub_index_size"] = props->user_collected_properties["plain_table_sub_index_size"] =
ToString(index_.GetSubIndexSize()); std::to_string(index_.GetSubIndexSize());
} else { } else {
props->user_collected_properties["plain_table_hash_table_size"] = props->user_collected_properties["plain_table_hash_table_size"] =
ToString(0); std::to_string(0);
props->user_collected_properties["plain_table_sub_index_size"] = props->user_collected_properties["plain_table_sub_index_size"] =
ToString(0); std::to_string(0);
} }
return Status::OK(); return Status::OK();

View File

@ -63,7 +63,7 @@ class SstFileWriterPropertiesCollector : public IntTblPropCollector {
} }
virtual UserCollectedProperties GetReadableProperties() const override { virtual UserCollectedProperties GetReadableProperties() const override {
return {{ExternalSstFilePropertyNames::kVersion, ToString(version_)}}; return {{ExternalSstFilePropertyNames::kVersion, std::to_string(version_)}};
} }
private: private:

View File

@ -39,9 +39,7 @@ namespace {
const TValue& value, const TValue& value,
const std::string& prop_delim, const std::string& prop_delim,
const std::string& kv_delim) { const std::string& kv_delim) {
AppendProperty( AppendProperty(props, key, std::to_string(value), prop_delim, kv_delim);
props, key, ToString(value), prop_delim, kv_delim
);
} }
} }
@ -107,7 +105,7 @@ std::string TableProperties::ToString(
ROCKSDB_NAMESPACE::TablePropertiesCollectorFactory:: ROCKSDB_NAMESPACE::TablePropertiesCollectorFactory::
Context::kUnknownColumnFamily Context::kUnknownColumnFamily
? std::string("N/A") ? std::string("N/A")
: ROCKSDB_NAMESPACE::ToString(column_family_id), : std::to_string(column_family_id),
prop_delim, kv_delim); prop_delim, kv_delim);
AppendProperty( AppendProperty(
result, "column family name", result, "column family name",

View File

@ -1377,9 +1377,9 @@ TEST_F(TablePropertyTest, PrefixScanTest) {
pos->first.compare(0, prefix.size(), prefix) == 0; pos->first.compare(0, prefix.size(), prefix) == 0;
++pos) { ++pos) {
++num; ++num;
auto key = prefix + "." + ToString(num); auto key = prefix + "." + std::to_string(num);
ASSERT_EQ(key, pos->first); ASSERT_EQ(key, pos->first);
ASSERT_EQ(ToString(num), pos->second); ASSERT_EQ(std::to_string(num), pos->second);
} }
ASSERT_EQ(3, num); ASSERT_EQ(3, num);
} }
@ -1705,7 +1705,7 @@ uint64_t BlockBasedTableTest::IndexUncompressedHelper(bool compressed) {
constexpr size_t kNumKeys = 10000; constexpr size_t kNumKeys = 10000;
for (size_t k = 0; k < kNumKeys; ++k) { for (size_t k = 0; k < kNumKeys; ++k) {
c.Add("key" + ToString(k), "val" + ToString(k)); c.Add("key" + std::to_string(k), "val" + std::to_string(k));
} }
std::vector<std::string> keys; std::vector<std::string> keys;

View File

@ -656,7 +656,7 @@ class SpecialSkipListFactory : public MemTableRepFactory {
std::string GetId() const override { std::string GetId() const override {
std::string id = Name(); std::string id = Name();
if (num_entries_flush_ > 0) { if (num_entries_flush_ > 0) {
id.append(":").append(ROCKSDB_NAMESPACE::ToString(num_entries_flush_)); id.append(":").append(std::to_string(num_entries_flush_));
} }
return id; return id;
} }

View File

@ -96,7 +96,7 @@ Status RandomTransactionInserter::DBGet(
assert(set_i + 1 <= 9999); assert(set_i + 1 <= 9999);
snprintf(prefix_buf, sizeof(prefix_buf), "%.4u", set_i + 1); snprintf(prefix_buf, sizeof(prefix_buf), "%.4u", set_i + 1);
// key format: [SET#][random#] // key format: [SET#][random#]
std::string skey = ToString(ikey); std::string skey = std::to_string(ikey);
Slice base_key(skey); Slice base_key(skey);
*full_key = std::string(prefix_buf) + base_key.ToString(); *full_key = std::string(prefix_buf) + base_key.ToString();
Slice key(*full_key); Slice key(*full_key);
@ -163,7 +163,7 @@ bool RandomTransactionInserter::DoInsert(DB* db, Transaction* txn,
if (s.ok()) { if (s.ok()) {
// Increment key // Increment key
std::string sum = ToString(int_value + incr); std::string sum = std::to_string(int_value + incr);
if (txn != nullptr) { if (txn != nullptr) {
if ((set_i % 4) != 0) { if ((set_i % 4) != 0) {
s = txn->SingleDelete(key); s = txn->SingleDelete(key);

View File

@ -1952,9 +1952,9 @@ class ReporterAgent {
auto secs_elapsed = auto secs_elapsed =
(clock->NowMicros() - time_started + kMicrosInSecond / 2) / (clock->NowMicros() - time_started + kMicrosInSecond / 2) /
kMicrosInSecond; kMicrosInSecond;
std::string report = ToString(secs_elapsed) + "," + std::string report =
ToString(total_ops_done_snapshot - last_report_) + std::to_string(secs_elapsed) + "," +
"\n"; std::to_string(total_ops_done_snapshot - last_report_) + "\n";
auto s = report_file_->Append(report); auto s = report_file_->Append(report);
if (s.ok()) { if (s.ok()) {
s = report_file_->Flush(); s = report_file_->Flush();
@ -2208,7 +2208,7 @@ class Stats {
if (db->GetProperty( if (db->GetProperty(
db_with_cfh->cfh[i], db_with_cfh->cfh[i],
"rocksdb.aggregated-table-properties-at-level" + "rocksdb.aggregated-table-properties-at-level" +
ToString(level), std::to_string(level),
&stats)) { &stats)) {
if (stats.find("# entries=0") == std::string::npos) { if (stats.find("# entries=0") == std::string::npos) {
fprintf(stderr, "Level[%d]: %s\n", level, fprintf(stderr, "Level[%d]: %s\n", level,
@ -2232,7 +2232,7 @@ class Stats {
for (int level = 0; level < FLAGS_num_levels; ++level) { for (int level = 0; level < FLAGS_num_levels; ++level) {
if (db->GetProperty( if (db->GetProperty(
"rocksdb.aggregated-table-properties-at-level" + "rocksdb.aggregated-table-properties-at-level" +
ToString(level), std::to_string(level),
&stats)) { &stats)) {
if (stats.find("# entries=0") == std::string::npos) { if (stats.find("# entries=0") == std::string::npos) {
fprintf(stderr, "Level[%d]: %s\n", level, stats.c_str()); fprintf(stderr, "Level[%d]: %s\n", level, stats.c_str());
@ -3142,7 +3142,7 @@ class Benchmark {
} }
#endif #endif
} }
return base_name + ToString(id); return base_name + std::to_string(id);
} }
void VerifyDBFromDB(std::string& truth_db_name) { void VerifyDBFromDB(std::string& truth_db_name) {
@ -3791,7 +3791,7 @@ class Benchmark {
static inline void ChecksumBenchmark(FnType fn, ThreadState* thread, static inline void ChecksumBenchmark(FnType fn, ThreadState* thread,
Args... args) { Args... args) {
const int size = FLAGS_block_size; // use --block_size option for db_bench const int size = FLAGS_block_size; // use --block_size option for db_bench
std::string labels = "(" + ToString(FLAGS_block_size) + " per op)"; std::string labels = "(" + std::to_string(FLAGS_block_size) + " per op)";
const char* label = labels.c_str(); const char* label = labels.c_str();
std::string data(size, 'x'); std::string data(size, 'x');
@ -4429,7 +4429,7 @@ class Benchmark {
Status s = FilterPolicy::CreateFromString( Status s = FilterPolicy::CreateFromString(
ConfigOptions(), ConfigOptions(),
"rocksdb.internal.DeprecatedBlockBasedBloomFilter:" + "rocksdb.internal.DeprecatedBlockBasedBloomFilter:" +
ROCKSDB_NAMESPACE::ToString(FLAGS_bloom_bits), std::to_string(FLAGS_bloom_bits),
&table_options->filter_policy); &table_options->filter_policy);
if (!s.ok()) { if (!s.ok()) {
fprintf(stderr, fprintf(stderr,

View File

@ -45,8 +45,8 @@ class SanityTest {
return s; return s;
} }
for (int i = 0; i < 1000000; ++i) { for (int i = 0; i < 1000000; ++i) {
std::string k = "key" + ToString(i); std::string k = "key" + std::to_string(i);
std::string v = "value" + ToString(i); std::string v = "value" + std::to_string(i);
s = db->Put(WriteOptions(), Slice(k), Slice(v)); s = db->Put(WriteOptions(), Slice(k), Slice(v));
if (!s.ok()) { if (!s.ok()) {
return s; return s;
@ -63,8 +63,8 @@ class SanityTest {
return s; return s;
} }
for (int i = 0; i < 1000000; ++i) { for (int i = 0; i < 1000000; ++i) {
std::string k = "key" + ToString(i); std::string k = "key" + std::to_string(i);
std::string v = "value" + ToString(i); std::string v = "value" + std::to_string(i);
std::string result; std::string result;
s = db->Get(ReadOptions(), Slice(k), &result); s = db->Get(ReadOptions(), Slice(k), &result);
if (!s.ok()) { if (!s.ok()) {

View File

@ -2198,8 +2198,7 @@ std::vector<std::string> ReduceDBLevelsCommand::PrepareArgs(
std::vector<std::string> ret; std::vector<std::string> ret;
ret.push_back("reduce_levels"); ret.push_back("reduce_levels");
ret.push_back("--" + ARG_DB + "=" + db_path); ret.push_back("--" + ARG_DB + "=" + db_path);
ret.push_back("--" + ARG_NEW_LEVELS + "=" + ret.push_back("--" + ARG_NEW_LEVELS + "=" + std::to_string(new_levels));
ROCKSDB_NAMESPACE::ToString(new_levels));
if(print_old_level) { if(print_old_level) {
ret.push_back("--" + ARG_PRINT_OLD_LEVELS); ret.push_back("--" + ARG_PRINT_OLD_LEVELS);
} }
@ -2393,7 +2392,8 @@ void ChangeCompactionStyleCommand::DoCommand() {
std::string property; std::string property;
std::string files_per_level; std::string files_per_level;
for (int i = 0; i < db_->NumberLevels(GetCfHandle()); i++) { for (int i = 0; i < db_->NumberLevels(GetCfHandle()); i++) {
db_->GetProperty(GetCfHandle(), "rocksdb.num-files-at-level" + ToString(i), db_->GetProperty(GetCfHandle(),
"rocksdb.num-files-at-level" + std::to_string(i),
&property); &property);
// format print string // format print string
@ -2421,7 +2421,8 @@ void ChangeCompactionStyleCommand::DoCommand() {
files_per_level = ""; files_per_level = "";
int num_files = 0; int num_files = 0;
for (int i = 0; i < db_->NumberLevels(GetCfHandle()); i++) { for (int i = 0; i < db_->NumberLevels(GetCfHandle()); i++) {
db_->GetProperty(GetCfHandle(), "rocksdb.num-files-at-level" + ToString(i), db_->GetProperty(GetCfHandle(),
"rocksdb.num-files-at-level" + std::to_string(i),
&property); &property);
// format print string // format print string
@ -2436,7 +2437,7 @@ void ChangeCompactionStyleCommand::DoCommand() {
exec_state_ = LDBCommandExecuteResult::Failed( exec_state_ = LDBCommandExecuteResult::Failed(
"Number of db files at " "Number of db files at "
"level 0 after compaction is " + "level 0 after compaction is " +
ToString(num_files) + ", not 1.\n"); std::to_string(num_files) + ", not 1.\n");
return; return;
} }
// other levels should have no file // other levels should have no file
@ -2444,8 +2445,8 @@ void ChangeCompactionStyleCommand::DoCommand() {
exec_state_ = LDBCommandExecuteResult::Failed( exec_state_ = LDBCommandExecuteResult::Failed(
"Number of db files at " "Number of db files at "
"level " + "level " +
ToString(i) + " after compaction is " + ToString(num_files) + std::to_string(i) + " after compaction is " +
", not 0.\n"); std::to_string(num_files) + ", not 0.\n");
return; return;
} }
} }

View File

@ -244,7 +244,7 @@ class FileChecksumTestHelper {
live_files[i].file_checksum_func_name != stored_func_name) { live_files[i].file_checksum_func_name != stored_func_name) {
return Status::Corruption( return Status::Corruption(
"Checksum does not match! The file: " + "Checksum does not match! The file: " +
ToString(live_files[i].file_number) + std::to_string(live_files[i].file_number) +
". In Manifest, checksum name: " + stored_func_name + ". In Manifest, checksum name: " + stored_func_name +
" and checksum " + stored_checksum + " and checksum " + stored_checksum +
". However, expected checksum name: " + ". However, expected checksum name: " +
@ -937,7 +937,7 @@ TEST_F(LdbCmdTest, UnsafeRemoveSstFile) {
// Create three SST files // Create three SST files
for (size_t i = 0; i < 3; ++i) { for (size_t i = 0; i < 3; ++i) {
ASSERT_OK(db->Put(WriteOptions(), ToString(i), ToString(i))); ASSERT_OK(db->Put(WriteOptions(), std::to_string(i), std::to_string(i)));
ASSERT_OK(db->Flush(FlushOptions())); ASSERT_OK(db->Flush(FlushOptions()));
} }
@ -985,7 +985,8 @@ TEST_F(LdbCmdTest, UnsafeRemoveSstFile) {
ColumnFamilyOptions cf_opts; ColumnFamilyOptions cf_opts;
ASSERT_OK(db->CreateColumnFamily(cf_opts, "cf1", &cf_handle)); ASSERT_OK(db->CreateColumnFamily(cf_opts, "cf1", &cf_handle));
for (size_t i = 3; i < 5; ++i) { for (size_t i = 3; i < 5; ++i) {
ASSERT_OK(db->Put(WriteOptions(), cf_handle, ToString(i), ToString(i))); ASSERT_OK(db->Put(WriteOptions(), cf_handle, std::to_string(i),
std::to_string(i)));
ASSERT_OK(db->Flush(FlushOptions(), cf_handle)); ASSERT_OK(db->Flush(FlushOptions(), cf_handle));
} }
@ -1048,7 +1049,7 @@ TEST_F(LdbCmdTest, FileTemperatureUpdateManifest) {
Temperature::kWarm, Temperature::kCold}; Temperature::kWarm, Temperature::kCold};
std::map<uint64_t, Temperature> number_to_temp; std::map<uint64_t, Temperature> number_to_temp;
for (size_t i = 0; i < kTestTemps.size(); ++i) { for (size_t i = 0; i < kTestTemps.size(); ++i) {
ASSERT_OK(db->Put(WriteOptions(), ToString(i), ToString(i))); ASSERT_OK(db->Put(WriteOptions(), std::to_string(i), std::to_string(i)));
ASSERT_OK(db->Flush(FlushOptions())); ASSERT_OK(db->Flush(FlushOptions()));
std::map<uint64_t, Temperature> current_temps; std::map<uint64_t, Temperature> current_temps;
@ -1069,8 +1070,8 @@ TEST_F(LdbCmdTest, FileTemperatureUpdateManifest) {
for (size_t i = 0; i < kTestTemps.size(); ++i) { for (size_t i = 0; i < kTestTemps.size(); ++i) {
std::string val; std::string val;
ASSERT_OK(db->Get(ReadOptions(), ToString(i), &val)); ASSERT_OK(db->Get(ReadOptions(), std::to_string(i), &val));
ASSERT_EQ(val, ToString(i)); ASSERT_EQ(val, std::to_string(i));
} }
// Still all unknown // Still all unknown
@ -1101,8 +1102,8 @@ TEST_F(LdbCmdTest, FileTemperatureUpdateManifest) {
for (size_t i = 0; i < kTestTemps.size(); ++i) { for (size_t i = 0; i < kTestTemps.size(); ++i) {
std::string val; std::string val;
ASSERT_OK(db->Get(ReadOptions(), ToString(i), &val)); ASSERT_OK(db->Get(ReadOptions(), std::to_string(i), &val));
ASSERT_EQ(val, ToString(i)); ASSERT_EQ(val, std::to_string(i));
} }
requests.clear(); requests.clear();

View File

@ -70,8 +70,8 @@ public:
int FilesOnLevel(int level) { int FilesOnLevel(int level) {
std::string property; std::string property;
EXPECT_TRUE(db_->GetProperty("rocksdb.num-files-at-level" + ToString(level), EXPECT_TRUE(db_->GetProperty(
&property)); "rocksdb.num-files-at-level" + std::to_string(level), &property));
return atoi(property.c_str()); return atoi(property.c_str());
} }

View File

@ -68,7 +68,7 @@ TEST_F(AutoVectorTest, EmplaceBack) {
autovector<ValType, kSize> vec; autovector<ValType, kSize> vec;
for (size_t i = 0; i < 1000 * kSize; ++i) { for (size_t i = 0; i < 1000 * kSize; ++i) {
vec.emplace_back(i, ToString(i + 123)); vec.emplace_back(i, std::to_string(i + 123));
ASSERT_TRUE(!vec.empty()); ASSERT_TRUE(!vec.empty());
if (i < kSize) { if (i < kSize) {
AssertAutoVectorOnlyInStack(&vec, true); AssertAutoVectorOnlyInStack(&vec, true);
@ -78,7 +78,7 @@ TEST_F(AutoVectorTest, EmplaceBack) {
ASSERT_EQ(i + 1, vec.size()); ASSERT_EQ(i + 1, vec.size());
ASSERT_EQ(i, vec[i].first); ASSERT_EQ(i, vec[i].first);
ASSERT_EQ(ToString(i + 123), vec[i].second); ASSERT_EQ(std::to_string(i + 123), vec[i].second);
} }
vec.clear(); vec.clear();
@ -146,7 +146,7 @@ TEST_F(AutoVectorTest, CopyAndAssignment) {
TEST_F(AutoVectorTest, Iterators) { TEST_F(AutoVectorTest, Iterators) {
autovector<std::string, kSize> vec; autovector<std::string, kSize> vec;
for (size_t i = 0; i < kSize * 1000; ++i) { for (size_t i = 0; i < kSize * 1000; ++i) {
vec.push_back(ToString(i)); vec.push_back(std::to_string(i));
} }
// basic operator test // basic operator test
@ -208,7 +208,7 @@ std::vector<std::string> GetTestKeys(size_t size) {
int index = 0; int index = 0;
for (auto& key : keys) { for (auto& key : keys) {
key = "item-" + ROCKSDB_NAMESPACE::ToString(index++); key = "item-" + std::to_string(index++);
} }
return keys; return keys;
} }

View File

@ -1257,7 +1257,7 @@ TEST_P(FullBloomTest, CorruptFilters) {
ASSERT_TRUE(Matches("hello")); ASSERT_TRUE(Matches("hello"));
ASSERT_TRUE(Matches("world")); ASSERT_TRUE(Matches("world"));
// Need many queries to find a "true negative" // Need many queries to find a "true negative"
for (int i = 0; Matches(ToString(i)); ++i) { for (int i = 0; Matches(std::to_string(i)); ++i) {
ASSERT_LT(i, 1000); ASSERT_LT(i, 1000);
} }

Some files were not shown because too many files have changed in this diff Show More