Skip to content

Commit

Permalink
internal_repo_rocksdb (-8794174668376270091)
Browse files Browse the repository at this point in the history
Differential Revision: D51745613

fbshipit-source-id: d020cf0aa8996340ecb981a772b21ba302415a67
  • Loading branch information
Andrew Kryczka authored and facebook-github-bot committed Dec 1, 2023
1 parent b760af3 commit 30476ca
Show file tree
Hide file tree
Showing 41 changed files with 165 additions and 140 deletions.
4 changes: 2 additions & 2 deletions logging/auto_roll_logger_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,8 @@ TEST_F(AutoRollLoggerTest, Close) {
static std::vector<std::string> GetOldFileNames(const std::string& path) {
std::vector<std::string> ret;

const std::string dirname = path.substr(/*start=*/0, path.find_last_of("/"));
const std::string fname = path.substr(path.find_last_of("/") + 1);
const std::string dirname = path.substr(/*start=*/0, path.find_last_of('/'));
const std::string fname = path.substr(path.find_last_of('/') + 1);

std::vector<std::string> children;
EXPECT_OK(Env::Default()->GetChildren(dirname, &children));
Expand Down
2 changes: 1 addition & 1 deletion logging/env_logger_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ TEST_F(EnvLoggerTest, ConcurrentLogging) {
const int kNumThreads = 5;
// Create threads.
for (int ii = 0; ii < kNumThreads; ++ii) {
threads.push_back(port::Thread(cb));
threads.emplace_back(cb);
}

// Wait for them to complete.
Expand Down
2 changes: 1 addition & 1 deletion memory/arena_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static void SimpleTest(size_t huge_page_size) {
r[b] = i % 256;
}
bytes += s;
allocated.push_back(std::make_pair(s, r));
allocated.emplace_back(s, r);
ASSERT_GE(arena.ApproximateMemoryUsage(), bytes);
if (i > N / 10) {
ASSERT_LE(arena.ApproximateMemoryUsage(), bytes * 1.10);
Expand Down
2 changes: 1 addition & 1 deletion memtable/alloc_tracker.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 <assert.h>
#include <cassert>

#include "memory/allocator.h"
#include "memory/arena.h"
Expand Down
10 changes: 5 additions & 5 deletions memtable/hash_linklist_rep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct Node {
void NoBarrier_SetNext(Node* x) { next_.store(x, std::memory_order_relaxed); }

// Needed for placement new below which is fine
Node() {}
Node() = default;

private:
std::atomic<Node*> next_;
Expand Down Expand Up @@ -265,7 +265,7 @@ class HashLinkListRep : public MemTableRep {
explicit FullListIterator(MemtableSkipList* list, Allocator* allocator)
: iter_(list), full_list_(list), allocator_(allocator) {}

~FullListIterator() override {}
~FullListIterator() override = default;

// Returns true iff the iterator is positioned at a valid node.
bool Valid() const override { return iter_.Valid(); }
Expand Down Expand Up @@ -332,7 +332,7 @@ class HashLinkListRep : public MemTableRep {
head_(head),
node_(nullptr) {}

~LinkListIterator() override {}
~LinkListIterator() override = default;

// Returns true iff the iterator is positioned at a valid node.
bool Valid() const override { return node_ != nullptr; }
Expand Down Expand Up @@ -482,7 +482,7 @@ class HashLinkListRep : public MemTableRep {
// This is used when there wasn't a bucket. It is cheaper than
// instantiating an empty bucket over which to iterate.
public:
EmptyIterator() {}
EmptyIterator() = default;
bool Valid() const override { return false; }
const char* key() const override {
assert(false);
Expand Down Expand Up @@ -526,7 +526,7 @@ HashLinkListRep::HashLinkListRep(
}
}

HashLinkListRep::~HashLinkListRep() {}
HashLinkListRep::~HashLinkListRep() = default;

KeyHandle HashLinkListRep::Allocate(const size_t len, char** buf) {
char* mem = allocator_->AllocateAligned(sizeof(Node) + len);
Expand Down
4 changes: 2 additions & 2 deletions memtable/hash_skiplist_rep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class HashSkipListRep : public MemTableRep {
// This is used when there wasn't a bucket. It is cheaper than
// instantiating an empty bucket over which to iterate.
public:
EmptyIterator() {}
EmptyIterator() = default;
bool Valid() const override { return false; }
const char* key() const override {
assert(false);
Expand Down Expand Up @@ -248,7 +248,7 @@ HashSkipListRep::HashSkipListRep(const MemTableRep::KeyComparator& compare,
}
}

HashSkipListRep::~HashSkipListRep() {}
HashSkipListRep::~HashSkipListRep() = default;

HashSkipListRep::Bucket* HashSkipListRep::GetInitializedBucket(
const Slice& transformed) {
Expand Down
6 changes: 3 additions & 3 deletions memtable/skiplistrep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class SkipListRep : public MemTableRep {
}
}

~SkipListRep() override {}
~SkipListRep() override = default;

// Iteration over the contents of a skip list
class Iterator : public MemTableRep::Iterator {
Expand All @@ -174,7 +174,7 @@ class SkipListRep : public MemTableRep {
const InlineSkipList<const MemTableRep::KeyComparator&>* list)
: iter_(list) {}

~Iterator() override {}
~Iterator() override = default;

// Returns true iff the iterator is positioned at a valid node.
bool Valid() const override { return iter_.Valid(); }
Expand Down Expand Up @@ -232,7 +232,7 @@ class SkipListRep : public MemTableRep {
explicit LookaheadIterator(const SkipListRep& rep)
: rep_(rep), iter_(&rep_.skip_list_), prev_(iter_) {}

~LookaheadIterator() override {}
~LookaheadIterator() override = default;

bool Valid() const override { return iter_.Valid(); }

Expand Down
4 changes: 2 additions & 2 deletions memtable/vectorrep.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class VectorRep : public MemTableRep {
void Get(const LookupKey& k, void* callback_args,
bool (*callback_func)(void* arg, const char* entry)) override;

~VectorRep() override {}
~VectorRep() override = default;

class Iterator : public MemTableRep::Iterator {
class VectorRep* vrep_;
Expand All @@ -59,7 +59,7 @@ class VectorRep : public MemTableRep {
// Initialize an iterator over the specified collection.
// The returned iterator is not valid.
// explicit Iterator(const MemTableRep* collection);
~Iterator() override{};
~Iterator() override= default;;

// Returns true iff the iterator is positioned at a valid node.
bool Valid() const override;
Expand Down
3 changes: 2 additions & 1 deletion microbench/db_basic_bench.cc
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ BENCHMARK(ManualFlush)->Iterations(1)->Apply(ManualFlushArguments);
static Slice CompressibleString(Random* rnd, double compressed_fraction,
int len, std::string* dst) {
int raw = static_cast<int>(len * compressed_fraction);
if (raw < 1) raw = 1;
if (raw < 1) { raw = 1;
}
std::string raw_data = rnd->RandomBinaryString(raw);

// Duplicate the random data until we have filled "len" bytes
Expand Down
22 changes: 14 additions & 8 deletions monitoring/histogram.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "monitoring/histogram.h"

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

#include <algorithm>
#include <cassert>
Expand Down Expand Up @@ -45,11 +45,12 @@ HistogramBucketMapper::HistogramBucketMapper() {
size_t HistogramBucketMapper::IndexForValue(const uint64_t value) const {
auto beg = bucketValues_.begin();
auto end = bucketValues_.end();
if (value >= maxBucketValue_)
if (value >= maxBucketValue_) {
return end - beg - 1; // bucketValues_.size() - 1
else
} else {
return std::lower_bound(beg, end, value) - beg;
}
}

namespace {
const HistogramBucketMapper bucketMapper;
Expand Down Expand Up @@ -147,8 +148,10 @@ double HistogramStat::Percentile(double p) const {
double r = left_point + (right_point - left_point) * pos;
uint64_t cur_min = min();
uint64_t cur_max = max();
if (r < cur_min) r = static_cast<double>(cur_min);
if (r > cur_max) r = static_cast<double>(cur_max);
if (r < cur_min) { r = static_cast<double>(cur_min);
}
if (r > cur_max) { r = static_cast<double>(cur_max);
}
return r;
}
}
Expand All @@ -158,7 +161,8 @@ double HistogramStat::Percentile(double p) const {
double HistogramStat::Average() const {
uint64_t cur_num = num();
uint64_t cur_sum = sum();
if (cur_num == 0) return 0;
if (cur_num == 0) { return 0;
}
return static_cast<double>(cur_sum) / static_cast<double>(cur_num);
}

Expand Down Expand Up @@ -193,12 +197,14 @@ std::string HistogramStat::ToString() const {
Percentile(99.99));
r.append(buf);
r.append("------------------------------------------------------\n");
if (cur_num == 0) return r; // all buckets are empty
if (cur_num == 0) { return r; // all buckets are empty
}
const double mult = 100.0 / cur_num;
uint64_t cumulative_sum = 0;
for (unsigned int b = 0; b < num_buckets_; b++) {
uint64_t bucket_value = bucket_at(b);
if (bucket_value <= 0.0) continue;
if (bucket_value <= 0.0) { continue;
}
cumulative_sum += bucket_value;
snprintf(buf, sizeof(buf),
"%c %7" PRIu64 ", %7" PRIu64 " ] %8" PRIu64 " %7.3f%% %7.3f%% ",
Expand Down
8 changes: 5 additions & 3 deletions monitoring/histogram_windowing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ HistogramWindowingImpl::HistogramWindowingImpl(uint64_t num_windows,
Clear();
}

HistogramWindowingImpl::~HistogramWindowingImpl() {}
HistogramWindowingImpl::~HistogramWindowingImpl() = default;

void HistogramWindowingImpl::Clear() {
std::lock_guard<std::mutex> lock(mutex_);
Expand Down Expand Up @@ -159,7 +159,8 @@ void HistogramWindowingImpl::SwapHistoryBucket() {
for (unsigned int i = 0; i < num_windows_; i++) {
if (i != next_window) {
uint64_t m = window_stats_[i].min();
if (m < new_min) new_min = m;
if (m < new_min) { new_min = m;
}
}
}
stats_.min_.store(new_min, std::memory_order_relaxed);
Expand All @@ -170,7 +171,8 @@ void HistogramWindowingImpl::SwapHistoryBucket() {
for (unsigned int i = 0; i < num_windows_; i++) {
if (i != next_window) {
uint64_t m = window_stats_[i].max();
if (m > new_max) new_max = m;
if (m > new_max) { new_max = m;
}
}
}
stats_.max_.store(new_max, std::memory_order_relaxed);
Expand Down
2 changes: 1 addition & 1 deletion monitoring/in_memory_stats_history.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace ROCKSDB_NAMESPACE {

InMemoryStatsHistoryIterator::~InMemoryStatsHistoryIterator() {}
InMemoryStatsHistoryIterator::~InMemoryStatsHistoryIterator() = default;

bool InMemoryStatsHistoryIterator::Valid() const { return valid_; }

Expand Down
2 changes: 1 addition & 1 deletion monitoring/perf_level.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// (found in the LICENSE.Apache file in the root directory).
//

#include <assert.h>
#include <cassert>

#include "monitoring/perf_level_imp.h"

Expand Down
4 changes: 2 additions & 2 deletions monitoring/persistent_stats_history.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void OptimizeForPersistentStats(ColumnFamilyOptions* cfo) {
cfo->compression = kNoCompression;
}

PersistentStatsHistoryIterator::~PersistentStatsHistoryIterator() {}
PersistentStatsHistoryIterator::~PersistentStatsHistoryIterator() = default;

bool PersistentStatsHistoryIterator::Valid() const { return valid_; }

Expand All @@ -96,7 +96,7 @@ std::pair<uint64_t, std::string> parseKey(const Slice& key,
uint64_t start_time) {
std::pair<uint64_t, std::string> result;
std::string key_str = key.ToString();
std::string::size_type pos = key_str.find("#");
std::string::size_type pos = key_str.find('#');
// TODO(Zhongyi): add counters to track parse failures?
if (pos == std::string::npos) {
result.first = std::numeric_limits<uint64_t>::max();
Expand Down
5 changes: 3 additions & 2 deletions monitoring/statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ StatisticsImpl::StatisticsImpl(std::shared_ptr<Statistics> stats)
RegisterOptions("StatisticsOptions", &stats_, &stats_type_info);
}

StatisticsImpl::~StatisticsImpl() {}
StatisticsImpl::~StatisticsImpl() = default;

uint64_t StatisticsImpl::getTickerCount(uint32_t tickerType) const {
MutexLock lock(&aggregate_lock_);
Expand Down Expand Up @@ -538,7 +538,8 @@ std::string StatisticsImpl::ToString() const {
bool StatisticsImpl::getTickerMap(
std::map<std::string, uint64_t>* stats_map) const {
assert(stats_map);
if (!stats_map) return false;
if (!stats_map) { return false;
}
stats_map->clear();
MutexLock lock(&aggregate_lock_);
for (const auto& t : TickersNameMap) {
Expand Down
2 changes: 1 addition & 1 deletion monitoring/thread_status_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const std::string ThreadStatus::MicrosToString(uint64_t micros) {

const std::string& ThreadStatus::GetOperationPropertyName(
ThreadStatus::OperationType op_type, int i) {
static const std::string empty_str = "";
static const std::string empty_str;
switch (op_type) {
case ThreadStatus::OP_COMPACTION:
if (i >= NUM_COMPACTION_PROPERTIES) {
Expand Down
10 changes: 5 additions & 5 deletions options/cf_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ static std::unordered_map<std::string, OptionTypeInfo>
// value, say, like "23", which would be assigned to
// max_table_files_size.
if (name == "compaction_options_fifo" &&
value.find("=") == std::string::npos) {
value.find('=') == std::string::npos) {
// Old format. Parse just a single uint64_t value.
auto options = static_cast<CompactionOptionsFIFO*>(addr);
options->max_table_files_size = ParseUint64(value);
Expand Down Expand Up @@ -529,7 +529,7 @@ static std::unordered_map<std::string, OptionTypeInfo>
// This is to handle backward compatibility, where
// compression_options was a ":" separated list.
if (name == kOptNameCompOpts &&
value.find("=") == std::string::npos) {
value.find('=') == std::string::npos) {
auto* compression = static_cast<CompressionOptions*>(addr);
return ParseCompressionOptions(value, name, *compression);
} else {
Expand All @@ -549,7 +549,7 @@ static std::unordered_map<std::string, OptionTypeInfo>
// This is to handle backward compatibility, where
// compression_options was a ":" separated list.
if (name == kOptNameBMCompOpts &&
value.find("=") == std::string::npos) {
value.find('=') == std::string::npos) {
auto* compression = static_cast<CompressionOptions*>(addr);
return ParseCompressionOptions(value, name, *compression);
} else {
Expand Down Expand Up @@ -627,7 +627,7 @@ static std::unordered_map<std::string, OptionTypeInfo>
{offsetof(struct ImmutableCFOptions,
max_write_buffer_number_to_maintain),
OptionType::kInt, OptionVerificationType::kNormal,
OptionTypeFlags::kNone, 0}},
OptionTypeFlags::kNone, nullptr}},
{"max_write_buffer_size_to_maintain",
{offsetof(struct ImmutableCFOptions,
max_write_buffer_size_to_maintain),
Expand All @@ -636,7 +636,7 @@ static std::unordered_map<std::string, OptionTypeInfo>
{"min_write_buffer_number_to_merge",
{offsetof(struct ImmutableCFOptions, min_write_buffer_number_to_merge),
OptionType::kInt, OptionVerificationType::kNormal,
OptionTypeFlags::kNone, 0}},
OptionTypeFlags::kNone, nullptr}},
{"num_levels",
{offsetof(struct ImmutableCFOptions, num_levels), OptionType::kInt,
OptionVerificationType::kNormal, OptionTypeFlags::kNone}},
Expand Down
Loading

0 comments on commit 30476ca

Please sign in to comment.