Skip to content

Commit

Permalink
Run clang format against files under tools/ and db_stress_tool/ (#10868)
Browse files Browse the repository at this point in the history
Summary:
Some lines of .h and .cc files are not properly fomatted. Clear them up with clang format.

Pull Request resolved: facebook/rocksdb#10868

Test Plan: Watch existing CI to pass

Reviewed By: ajkr

Differential Revision: D40683485

fbshipit-source-id: 491fbb78b2cdcb948164f306829909ad816d5d0b
  • Loading branch information
siying authored and facebook-github-bot committed Oct 25, 2022
1 parent 95a1935 commit 48fe921
Show file tree
Hide file tree
Showing 18 changed files with 410 additions and 426 deletions.
4 changes: 2 additions & 2 deletions db_stress_tool/batched_ops_stress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ class BatchedOpsStressTest : public StressTest {
const std::vector<int64_t>& rand_keys) override {
size_t num_keys = rand_keys.size();
std::vector<Status> ret_status(num_keys);
std::array<std::string, 10> keys = {{"0", "1", "2", "3", "4",
"5", "6", "7", "8", "9"}};
std::array<std::string, 10> keys = {
{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}};
size_t num_prefixes = keys.size();
for (size_t rand_key = 0; rand_key < num_keys; ++rand_key) {
std::vector<Slice> key_slices;
Expand Down
4 changes: 2 additions & 2 deletions db_stress_tool/db_stress_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ extern inline std::string Key(int64_t val) {
if (offset < weight) {
// Use the bottom 3 bits of offset as the number of trailing 'x's in the
// key. If the next key is going to be of the next level, then skip the
// trailer as it would break ordering. If the key length is already at max,
// skip the trailer.
// trailer as it would break ordering. If the key length is already at
// max, skip the trailer.
if (offset < weight - 1 && level < levels - 1) {
size_t trailer_len = offset & 0x7;
key.append(trailer_len, 'x');
Expand Down
4 changes: 1 addition & 3 deletions db_stress_tool/db_stress_shared_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,7 @@ class SharedState {
uint64_t GetStartTimestamp() const { return start_timestamp_; }

private:
static void IgnoreReadErrorCallback(void*) {
ignore_read_error = true;
}
static void IgnoreReadErrorCallback(void*) { ignore_read_error = true; }

// Pick random keys in each column family that will not experience overwrite.
std::unordered_set<int64_t> GenerateNoOverwriteIds() const {
Expand Down
1 change: 1 addition & 0 deletions tools/blob_dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#ifndef ROCKSDB_LITE
#include <getopt.h>

#include <cstdio>
#include <string>
#include <unordered_map>
Expand Down
18 changes: 11 additions & 7 deletions tools/block_cache_analyzer/block_cache_trace_analyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,8 @@ void BlockCacheTraceAnalyzer::WriteReuseLifetime(
}

void BlockCacheTraceAnalyzer::WriteBlockReuseTimeline(
const uint64_t reuse_window, bool user_access_only, TraceType block_type) const {
const uint64_t reuse_window, bool user_access_only,
TraceType block_type) const {
// A map from block key to an array of bools that states whether a block is
// accessed in a time window.
std::map<uint64_t, std::vector<bool>> block_accessed;
Expand Down Expand Up @@ -1214,7 +1215,8 @@ void BlockCacheTraceAnalyzer::WriteBlockReuseTimeline(
TraverseBlocks(block_callback);

// A cell is the number of blocks accessed in a reuse window.
std::unique_ptr<uint64_t[]> reuse_table(new uint64_t[reuse_vector_size * reuse_vector_size]);
std::unique_ptr<uint64_t[]> reuse_table(
new uint64_t[reuse_vector_size * reuse_vector_size]);
for (uint64_t start_time = 0; start_time < reuse_vector_size; start_time++) {
// Initialize the reuse_table.
for (uint64_t i = 0; i < reuse_vector_size; i++) {
Expand Down Expand Up @@ -1255,8 +1257,9 @@ void BlockCacheTraceAnalyzer::WriteBlockReuseTimeline(
if (j < start_time) {
row += "100.0";
} else {
row += std::to_string(percent(reuse_table[start_time * reuse_vector_size + j],
reuse_table[start_time * reuse_vector_size + start_time]));
row += std::to_string(
percent(reuse_table[start_time * reuse_vector_size + j],
reuse_table[start_time * reuse_vector_size + start_time]));
}
}
out << row << std::endl;
Expand Down Expand Up @@ -1811,9 +1814,10 @@ void BlockCacheTraceAnalyzer::PrintDataBlockAccessStats() const {
return;
}
// Use four decimal points.
uint64_t percent_referenced_for_existing_keys = (uint64_t)(
((double)block.key_num_access_map.size() / (double)block.num_keys) *
10000.0);
uint64_t percent_referenced_for_existing_keys =
(uint64_t)(((double)block.key_num_access_map.size() /
(double)block.num_keys) *
10000.0);
uint64_t percent_referenced_for_non_existing_keys =
(uint64_t)(((double)block.non_exist_key_num_access_map.size() /
(double)block.num_keys) *
Expand Down
5 changes: 3 additions & 2 deletions tools/block_cache_analyzer/block_cache_trace_analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ struct BlockAccessInfo {
ParsedInternalKey internal_key;
Status s = ParseInternalKey(access.referenced_key, &internal_key,
false /* log_err_key */); // TODO
assert(s.ok()); // TODO
assert(s.ok()); // TODO
}
} else {
non_exist_key_num_access_map[access.referenced_key][access.caller]++;
Expand Down Expand Up @@ -292,7 +292,8 @@ class BlockCacheTraceAnalyzer {
// The file is named
// "block_type_user_access_only_reuse_window_reuse_timeline". The file format
// is start_time,0,1,...,N where N equals trace_duration / reuse_window.
void WriteBlockReuseTimeline(const uint64_t reuse_window, bool user_access_only,
void WriteBlockReuseTimeline(const uint64_t reuse_window,
bool user_access_only,
TraceType block_type) const;

// Write the Get spatical locality into csv files saved in 'output_dir'.
Expand Down
Loading

0 comments on commit 48fe921

Please sign in to comment.