Skip to content

Commit

Permalink
internal_repo_rocksdb (2794583611362153785)
Browse files Browse the repository at this point in the history
Differential Revision: D52559771
  • Loading branch information
CodemodService Bot authored and facebook-github-bot committed Jan 5, 2024
1 parent 5da900f commit 646e875
Show file tree
Hide file tree
Showing 29 changed files with 168 additions and 172 deletions.
2 changes: 1 addition & 1 deletion db/db_info_dumper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "db/db_info_dumper.h"

#include <stdio.h>
#include <cstdio>

#include <algorithm>
#include <cinttypes>
Expand Down
39 changes: 25 additions & 14 deletions db/db_iter_stress_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ struct Entry {
bool visible = true;

bool operator<(const Entry& e) const {
if (key != e.key) return key < e.key;
if (key != e.key) { return key < e.key;
}
return std::tie(sequence, type) > std::tie(e.sequence, e.type);
}
};
Expand Down Expand Up @@ -177,15 +178,17 @@ struct StressTestIterator : public InternalIterator {
}

void SeekToFirst() override {
if (MaybeFail()) return;
if (MaybeFail()) { return;
}
MaybeMutate();

status_ = Status::OK();
iter = 0;
SkipForward();
}
void SeekToLast() override {
if (MaybeFail()) return;
if (MaybeFail()) { return;
}
MaybeMutate();

status_ = Status::OK();
Expand All @@ -194,7 +197,8 @@ struct StressTestIterator : public InternalIterator {
}

void Seek(const Slice& target) override {
if (MaybeFail()) return;
if (MaybeFail()) { return;
}
MaybeMutate();

status_ = Status::OK();
Expand All @@ -206,7 +210,8 @@ struct StressTestIterator : public InternalIterator {
SkipForward();
}
void SeekForPrev(const Slice& target) override {
if (MaybeFail()) return;
if (MaybeFail()) { return;
}
MaybeMutate();

status_ = Status::OK();
Expand All @@ -221,14 +226,16 @@ struct StressTestIterator : public InternalIterator {

void Next() override {
assert(Valid());
if (MaybeFail()) return;
if (MaybeFail()) { return;
}
MaybeMutate();
++iter;
SkipForward();
}
void Prev() override {
assert(Valid());
if (MaybeFail()) return;
if (MaybeFail()) { return;
}
MaybeMutate();
--iter;
SkipBackward();
Expand Down Expand Up @@ -318,7 +325,8 @@ struct ReferenceIterator {
return false;
}
assert(e.sequence <= sequence);
if (!e.visible) continue;
if (!e.visible) { continue;
}
if (e.type == kTypeDeletion) {
return false;
}
Expand All @@ -339,11 +347,12 @@ struct ReferenceIterator {
break;
}
assert(e.sequence <= sequence);
if (!e.visible) continue;
if (!e.visible) { continue;
}
if (e.type == kTypeDeletion) {
break;
}
operands.push_back(e.value);
operands.emplace_back(e.value);
if (e.type == kTypeValue) {
break;
}
Expand Down Expand Up @@ -588,15 +597,17 @@ TEST_F(DBIteratorStressTest, StressTest) {

// Check that the key moved in the right direction.
if (forward) {
if (seek)
if (seek) {
ASSERT_GE(db_iter->key().ToString(), old_key);
else
} else {
ASSERT_GT(db_iter->key().ToString(), old_key);
}
} else {
if (seek)
if (seek) {
ASSERT_LE(db_iter->key().ToString(), old_key);
else
} else {
ASSERT_LT(db_iter->key().ToString(), old_key);
}
}

if (ref_iter->Valid()) {
Expand Down
5 changes: 2 additions & 3 deletions db/db_iter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ class TestIterator : public InternalIterator {
size_t seq_num, bool update_iter = false) {
valid_ = true;
ParsedInternalKey internal_key(argkey, seq_num, type);
data_.push_back(
std::pair<std::string, std::string>(std::string(), argvalue));
data_.emplace_back(std::string(), argvalue);
AppendInternalKey(&data_.back().first, internal_key);
if (update_iter && valid_ && cmp.Compare(data_.back().first, key()) < 0) {
// insert a key smaller than current key
Expand Down Expand Up @@ -2617,7 +2616,7 @@ class DBIterWithMergeIterTest : public testing::Test {
child_iters.push_back(internal_iter2_);
InternalKeyComparator icomp(BytewiseComparator());
InternalIterator* merge_iter =
NewMergingIterator(&icomp_, &child_iters[0], 2u);
NewMergingIterator(&icomp_, child_iters.data(), 2u);

db_iter_.reset(NewDBIterator(
env_, ro_, ImmutableOptions(options_), MutableCFOptions(options_),
Expand Down
2 changes: 1 addition & 1 deletion db/db_iterator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ TEST_F(DBIteratorBaseTest, APICallsWithPerfContext) {
class DBIteratorTest : public DBIteratorBaseTest,
public testing::WithParamInterface<bool> {
public:
DBIteratorTest() {}
DBIteratorTest() = default;

Iterator* NewIterator(const ReadOptions& read_options,
ColumnFamilyHandle* column_family = nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion db/db_kv_checksum_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ TEST_F(DbKVChecksumWALToWriteBatchTest, WriteBatchChecksumHandoff) {
Options options = CurrentOptions();
Reopen(options);
ASSERT_OK(db_->Put(WriteOptions(), "key", "val"));
std::string content = "";
std::string content;
SyncPoint::GetInstance()->SetCallBack(
"DBImpl::RecoverLogFiles:BeforeUpdateProtectionInfo:batch",
[&](void* batch_ptr) {
Expand Down
4 changes: 2 additions & 2 deletions db/db_options_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1146,11 +1146,11 @@ TEST_F(DBOptionsTest, OffpeakTimes) {
"1:0000000000000-2:000000000042", // Weird, but we can parse the int.
};

for (std::string invalid_case : invalid_cases) {
for (const std::string& invalid_case : invalid_cases) {
options.daily_offpeak_time_utc = invalid_case;
verify_invalid();
}
for (std::string valid_case : valid_cases) {
for (const std::string& valid_case : valid_cases) {
options.daily_offpeak_time_utc = valid_case;
verify_valid();
}
Expand Down
2 changes: 1 addition & 1 deletion db/db_properties_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.

#include <stdio.h>
#include <cstdio>

#include <algorithm>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion db/db_range_del_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DBRangeDelTest : public DBTestBase {
uint64_t uint64_key = static_cast<uint64_t>(key);
std::string str;
str.resize(8);
memcpy(&str[0], static_cast<void*>(&uint64_key), 8);
memcpy(str.data(), static_cast<void*>(&uint64_key), 8);
return str;
}
};
Expand Down
2 changes: 1 addition & 1 deletion db/db_secondary_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void DBSecondaryTestBase::CheckFileTypeCounts(const std::string& dir,
ASSERT_OK(env_->GetChildren(dir, &filenames));

int log_cnt = 0, sst_cnt = 0, manifest_cnt = 0;
for (auto file : filenames) {
for (const auto& file : filenames) {
uint64_t number;
FileType type;
if (ParseFileName(file, &number, &type)) {
Expand Down
14 changes: 7 additions & 7 deletions db/db_sst_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class DBSSTTest : public DBTestBase {
// A class which remembers the name of each flushed file.
class FlushedFileCollector : public EventListener {
public:
FlushedFileCollector() {}
~FlushedFileCollector() override {}
FlushedFileCollector() = default;
~FlushedFileCollector() override = default;

void OnFlushCompleted(DB* /*db*/, const FlushJobInfo& info) override {
std::lock_guard<std::mutex> lock(mutex_);
Expand All @@ -38,7 +38,7 @@ class FlushedFileCollector : public EventListener {
std::vector<std::string> GetFlushedFiles() {
std::lock_guard<std::mutex> lock(mutex_);
std::vector<std::string> result;
for (auto fname : flushed_files_) {
for (const auto& fname : flushed_files_) {
result.push_back(fname);
}
return result;
Expand Down Expand Up @@ -661,7 +661,7 @@ class DBSSTTestRateLimit : public DBSSTTest,
public ::testing::WithParamInterface<bool> {
public:
DBSSTTestRateLimit() : DBSSTTest() {}
~DBSSTTestRateLimit() override {}
~DBSSTTestRateLimit() override = default;
};

TEST_P(DBSSTTestRateLimit, RateLimitedDelete) {
Expand Down Expand Up @@ -1093,10 +1093,10 @@ TEST_F(DBSSTTest, DestroyDBWithRateLimitedDelete) {
int num_wal_files = 0;
std::vector<std::string> db_files;
ASSERT_OK(env_->GetChildren(dbname_, &db_files));
for (std::string f : db_files) {
if (f.substr(f.find_last_of(".") + 1) == "sst") {
for (const std::string& f : db_files) {
if (f.substr(f.find_last_of('.') + 1) == "sst") {
num_sst_files++;
} else if (f.substr(f.find_last_of(".") + 1) == "log") {
} else if (f.substr(f.find_last_of('.') + 1) == "log") {
num_wal_files++;
}
}
Expand Down
6 changes: 3 additions & 3 deletions db/db_table_properties_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ DBTablePropertiesTest::TestGetPropertiesOfTablesInRange(
// run the query
TablePropertiesCollection props;
EXPECT_OK(db_->GetPropertiesOfTablesInRange(
db_->DefaultColumnFamily(), &ranges[0], ranges.size(), &props));
db_->DefaultColumnFamily(), ranges.data(), ranges.size(), &props));

// Make sure that we've received properties for those and for those files
// only which fall within requested ranges
Expand Down Expand Up @@ -363,7 +363,7 @@ TEST_F(DBTablePropertiesTest, GetPropertiesOfTablesInRange) {
std::vector<Range> ranges;
auto it = random_keys.begin();
while (it != random_keys.end()) {
ranges.push_back(Range(*it, *(it + 1)));
ranges.emplace_back(*it, *(it + 1));
it += 2;
}

Expand Down Expand Up @@ -453,7 +453,7 @@ TEST_F(DBTablePropertiesTest, FactoryReturnsNull) {
std::make_shared<SometimesTablePropertiesCollectorFactory>());
// For plain table
options.prefix_extractor.reset(NewFixedPrefixTransform(4));
for (std::shared_ptr<TableFactory> tf :
for (const std::shared_ptr<TableFactory>& tf :
{options.table_factory,
std::shared_ptr<TableFactory>(NewPlainTableFactory({}))}) {
SCOPED_TRACE("Table factory = " + std::string(tf->Name()));
Expand Down
3 changes: 2 additions & 1 deletion db/db_tailing_iter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,9 @@ TEST_P(DBTestTailingIterator, TailingIteratorDeletes) {

// make sure we can read all new records using the existing iterator
int count = 0;
for (; iter->Valid(); iter->Next(), ++count)
for (; iter->Valid(); iter->Next(), ++count) {
;
}
ASSERT_OK(iter->status());
ASSERT_EQ(count, num_records);
}
Expand Down
Loading

0 comments on commit 646e875

Please sign in to comment.