Run Clang format on file folder (#10860)

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

Test Plan: CircleCI jobs

Reviewed By: anand1976

Differential Revision: D40656236

Pulled By: akankshamahajan15

fbshipit-source-id: 557600db5c2e0ab9b400655336c467307f7136de
main
akankshamahajan 2 years ago committed by Facebook GitHub Bot
parent 935aae3bcf
commit 671753c43d
  1. 7
      file/delete_scheduler.cc
  2. 5
      file/delete_scheduler.h
  3. 1
      file/delete_scheduler_test.cc
  4. 2
      file/file_util.cc
  5. 27
      file/filename.cc
  6. 9
      file/filename.h
  7. 42
      file/prefetch_test.cc
  8. 4
      file/random_access_file_reader_test.cc
  9. 1
      file/read_write_util.cc
  10. 1
      file/read_write_util.h
  11. 12
      file/sst_file_manager_impl.cc
  12. 3
      file/sst_file_manager_impl.h

@ -61,7 +61,8 @@ DeleteScheduler::~DeleteScheduler() {
Status DeleteScheduler::DeleteFile(const std::string& file_path,
const std::string& dir_to_sync,
const bool force_bg) {
if (rate_bytes_per_sec_.load() <= 0 || (!force_bg &&
if (rate_bytes_per_sec_.load() <= 0 ||
(!force_bg &&
total_trash_size_.load() >
sst_file_manager_->GetTotalSize() * max_trash_db_ratio_.load())) {
// Rate limiting is disabled or trash size makes up more than
@ -318,8 +319,8 @@ Status DeleteScheduler::DeleteTrashFile(const std::string& path_in_trash,
if (my_status.ok()) {
if (num_hard_links == 1) {
std::unique_ptr<FSWritableFile> wf;
my_status = fs_->ReopenWritableFile(path_in_trash, FileOptions(),
&wf, nullptr);
my_status = fs_->ReopenWritableFile(path_in_trash, FileOptions(), &wf,
nullptr);
if (my_status.ok()) {
my_status = wf->Truncate(file_size - bytes_max_delete_chunk_,
IOOptions(), nullptr);

@ -14,7 +14,6 @@
#include "monitoring/instrumented_mutex.h"
#include "port/port.h"
#include "rocksdb/status.h"
namespace ROCKSDB_NAMESPACE {
@ -67,9 +66,7 @@ class DeleteScheduler {
uint64_t GetTotalTrashSize() { return total_trash_size_.load(); }
// Return trash/DB size ratio where new files will be deleted immediately
double GetMaxTrashDBRatio() {
return max_trash_db_ratio_.load();
}
double GetMaxTrashDBRatio() { return max_trash_db_ratio_.load(); }
// Update trash/DB size ratio where new files will be deleted immediately
void SetMaxTrashDBRatio(double r) {

@ -591,7 +591,6 @@ TEST_F(DeleteSchedulerTest, DISABLED_DynamicRateLimiting1) {
rate_bytes_per_sec_ = 0; // Disable rate limiting initially
NewDeleteScheduler();
int num_files = 10; // 10 files
uint64_t file_size = 1024; // every file is 1 kb

@ -5,8 +5,8 @@
//
#include "file/file_util.h"
#include <string>
#include <algorithm>
#include <string>
#include "file/random_access_file_reader.h"
#include "file/sequence_file_reader.h"

@ -7,11 +7,13 @@
// 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 "file/filename.h"
#include <cinttypes>
#include <ctype.h>
#include <stdio.h>
#include <cinttypes>
#include <vector>
#include "file/writable_file_writer.h"
#include "rocksdb/env.h"
#include "test_util/sync_point.h"
@ -42,10 +44,8 @@ static size_t GetInfoLogPrefix(const std::string& path, char* dest, int len) {
while (i < src_len && write_idx < len - sizeof(suffix)) {
if ((path[i] >= 'a' && path[i] <= 'z') ||
(path[i] >= '0' && path[i] <= '9') ||
(path[i] >= 'A' && path[i] <= 'Z') ||
path[i] == '-' ||
path[i] == '.' ||
path[i] == '_'){
(path[i] >= 'A' && path[i] <= 'Z') || path[i] == '-' ||
path[i] == '.' || path[i] == '_') {
dest[write_idx++] = path[i];
} else {
if (i > 0) {
@ -153,7 +153,8 @@ void FormatFileNumber(uint64_t number, uint32_t path_id, char* out_buf,
if (path_id == 0) {
snprintf(out_buf, out_buf_size, "%" PRIu64, number);
} else {
snprintf(out_buf, out_buf_size, "%" PRIu64
snprintf(out_buf, out_buf_size,
"%" PRIu64
"(path "
"%" PRIu32 ")",
number, path_id);
@ -176,9 +177,7 @@ std::string CurrentFileName(const std::string& dbname) {
return dbname + "/" + kCurrentFileName;
}
std::string LockFileName(const std::string& dbname) {
return dbname + "/LOCK";
}
std::string LockFileName(const std::string& dbname) { return dbname + "/LOCK"; }
std::string TempFileName(const std::string& dbname, uint64_t number) {
return MakeFileName(dbname, number, kTempFileNameSuffix.c_str());
@ -199,7 +198,8 @@ InfoLogPrefix::InfoLogPrefix(bool has_log_dir,
}
std::string InfoLogFileName(const std::string& dbname,
const std::string& db_path, const std::string& log_dir) {
const std::string& db_path,
const std::string& log_dir) {
if (log_dir.empty()) {
return dbname + "/LOG";
}
@ -210,7 +210,8 @@ std::string InfoLogFileName(const std::string& dbname,
// Return the name of the old info log file for "dbname".
std::string OldInfoLogFileName(const std::string& dbname, uint64_t ts,
const std::string& db_path, const std::string& log_dir) {
const std::string& db_path,
const std::string& log_dir) {
char buf[50];
snprintf(buf, sizeof(buf), "%llu", static_cast<unsigned long long>(ts));
@ -263,9 +264,7 @@ std::string IdentityFileName(const std::string& dbname) {
// dbname/OPTIONS-[0-9]+
// dbname/OPTIONS-[0-9]+.dbtmp
// Disregards / at the beginning
bool ParseFileName(const std::string& fname,
uint64_t* number,
FileType* type,
bool ParseFileName(const std::string& fname, uint64_t* number, FileType* type,
WalFileType* log_type) {
return ParseFileName(fname, number, "", type, log_type);
}

@ -11,8 +11,9 @@
#pragma once
#include <stdint.h>
#include <unordered_map>
#include <string>
#include <unordered_map>
#include <vector>
#include "options/db_options.h"
@ -54,8 +55,7 @@ extern std::string ArchivalDirectory(const std::string& dbname);
// Return the name of the archived log file with the specified number
// in the db named by "dbname". The result will be prefixed with "dbname".
extern std::string ArchivedLogFileName(const std::string& dbname,
uint64_t num);
extern std::string ArchivedLogFileName(const std::string& dbname, uint64_t num);
extern std::string MakeTableFileName(const std::string& name, uint64_t number);
@ -140,8 +140,7 @@ extern std::string TempOptionsFileName(const std::string& dbname,
// Return the name to use for a metadatabase. The result will be prefixed with
// "dbname".
extern std::string MetaDatabaseName(const std::string& dbname,
uint64_t number);
extern std::string MetaDatabaseName(const std::string& dbname, uint64_t number);
// Return the name of the Identity file which stores a unique number for the db
// that will get regenerated if the db loses all its data and is recreated fresh

@ -1455,10 +1455,10 @@ extern "C" bool RocksDbIOUringEnable() { return true; }
namespace {
#ifndef ROCKSDB_LITE
#ifdef GFLAGS
const int kMaxArgCount = 100;
const size_t kArgBufferSize = 100000;
const int kMaxArgCount = 100;
const size_t kArgBufferSize = 100000;
void RunIOTracerParserTool(std::string trace_file) {
void RunIOTracerParserTool(std::string trace_file) {
std::vector<std::string> params = {"./io_tracer_parser",
"-io_trace_file=" + trace_file};
@ -1476,13 +1476,13 @@ namespace {
cursor += static_cast<int>(arg.size()) + 1;
}
ASSERT_EQ(0, ROCKSDB_NAMESPACE::io_tracer_parser(argc, argv));
}
}
#endif // GFLAGS
#endif // ROCKSDB_LITE
} // namespace
} // namespace
// Tests the default implementation of ReadAsync API with PosixFileSystem.
TEST_P(PrefetchTest, ReadAsyncWithPosixFS) {
TEST_P(PrefetchTest, ReadAsyncWithPosixFS) {
if (mem_env_ || encrypted_env_) {
ROCKSDB_GTEST_SKIP("Test requires non-mem or non-encrypted environment");
return;
@ -1619,8 +1619,7 @@ namespace {
// Check stats to make sure async prefetch is done.
{
HistogramData async_read_bytes;
options.statistics->histogramData(ASYNC_READ_BYTES,
&async_read_bytes);
options.statistics->histogramData(ASYNC_READ_BYTES, &async_read_bytes);
HistogramData prefetched_bytes_discarded;
options.statistics->histogramData(PREFETCHED_BYTES_DISCARDED,
&prefetched_bytes_discarded);
@ -1643,9 +1642,9 @@ namespace {
SyncPoint::GetInstance()->ClearAllCallBacks();
Close();
}
}
TEST_P(PrefetchTest, MultipleSeekWithPosixFS) {
TEST_P(PrefetchTest, MultipleSeekWithPosixFS) {
if (mem_env_ || encrypted_env_) {
ROCKSDB_GTEST_SKIP("Test requires non-mem or non-encrypted environment");
return;
@ -1761,8 +1760,7 @@ namespace {
// Check stats to make sure async prefetch is done.
{
HistogramData async_read_bytes;
options.statistics->histogramData(ASYNC_READ_BYTES,
&async_read_bytes);
options.statistics->histogramData(ASYNC_READ_BYTES, &async_read_bytes);
// Not all platforms support iouring. In that case, ReadAsync in posix
// won't submit async requests.
@ -1796,8 +1794,7 @@ namespace {
// Check stats to make sure async prefetch is done.
{
HistogramData async_read_bytes;
options.statistics->histogramData(ASYNC_READ_BYTES,
&async_read_bytes);
options.statistics->histogramData(ASYNC_READ_BYTES, &async_read_bytes);
HistogramData prefetched_bytes_discarded;
options.statistics->histogramData(PREFETCHED_BYTES_DISCARDED,
&prefetched_bytes_discarded);
@ -1819,9 +1816,9 @@ namespace {
SyncPoint::GetInstance()->DisableProcessing();
SyncPoint::GetInstance()->ClearAllCallBacks();
Close();
}
}
TEST_P(PrefetchTest, SeekParallelizationTest1) {
TEST_P(PrefetchTest, SeekParallelizationTest1) {
if (mem_env_ || encrypted_env_) {
ROCKSDB_GTEST_SKIP("Test requires non-mem or non-encrypted environment");
return;
@ -1899,8 +1896,7 @@ namespace {
ASSERT_OK(options.statistics->Reset());
// Each block contains around 4 keys.
auto iter = std::unique_ptr<Iterator>(db_->NewIterator(ro));
iter->Seek(
BuildKey(0)); // Prefetch data because of seek parallelization.
iter->Seek(BuildKey(0)); // Prefetch data because of seek parallelization.
ASSERT_TRUE(iter->Valid());
iter->Next();
ASSERT_TRUE(iter->Valid());
@ -1948,11 +1944,11 @@ namespace {
buff_prefetch_count = 0;
}
Close();
}
}
#ifndef ROCKSDB_LITE
#ifdef GFLAGS
TEST_P(PrefetchTest, TraceReadAsyncWithCallbackWrapper) {
TEST_P(PrefetchTest, TraceReadAsyncWithCallbackWrapper) {
if (mem_env_ || encrypted_env_) {
ROCKSDB_GTEST_SKIP("Test requires non-mem or non-encrypted environment");
return;
@ -2033,8 +2029,8 @@ namespace {
std::unique_ptr<TraceWriter> trace_writer;
std::string trace_file_path = dbname_ + "/io_trace_file";
ASSERT_OK(NewFileTraceWriter(env_, EnvOptions(), trace_file_path,
&trace_writer));
ASSERT_OK(
NewFileTraceWriter(env_, EnvOptions(), trace_file_path, &trace_writer));
ASSERT_OK(db_->StartIOTrace(trace_opt, std::move(trace_writer)));
ASSERT_OK(options.statistics->Reset());
@ -2073,7 +2069,7 @@ namespace {
SyncPoint::GetInstance()->ClearAllCallBacks();
Close();
}
}
#endif // GFLAGS
#endif // ROCKSDB_LITE
} // namespace ROCKSDB_NAMESPACE

@ -60,9 +60,7 @@ class RandomAccessFileReaderTest : public testing::Test {
std::shared_ptr<FileSystem> fs_;
std::string test_dir_;
std::string Path(const std::string& fname) {
return test_dir_ + "/" + fname;
}
std::string Path(const std::string& fname) { return test_dir_ + "/" + fname; }
};
// Skip the following tests in lite mode since direct I/O is unsupported.

@ -10,6 +10,7 @@
#include "file/read_write_util.h"
#include <sstream>
#include "test_util/sync_point.h"
namespace ROCKSDB_NAMESPACE {

@ -9,6 +9,7 @@
#pragma once
#include <atomic>
#include "file/sequence_file_reader.h"
#include "rocksdb/env.h"
#include "rocksdb/file_system.h"

@ -161,9 +161,8 @@ bool SstFileManagerImpl::EnoughRoomForCompaction(
// Update cur_compactions_reserved_size_ so concurrent compaction
// don't max out space
size_t needed_headroom =
cur_compactions_reserved_size_ + size_added_by_compaction +
compaction_buffer_size_;
size_t needed_headroom = cur_compactions_reserved_size_ +
size_added_by_compaction + compaction_buffer_size_;
if (max_allowed_space_ != 0 &&
(needed_headroom + total_files_size_ > max_allowed_space_)) {
return false;
@ -415,13 +414,12 @@ bool SstFileManagerImpl::CancelErrorRecovery(ErrorHandler* handler) {
return false;
}
Status SstFileManagerImpl::ScheduleFileDeletion(
const std::string& file_path, const std::string& path_to_sync,
Status SstFileManagerImpl::ScheduleFileDeletion(const std::string& file_path,
const std::string& path_to_sync,
const bool force_bg) {
TEST_SYNC_POINT_CALLBACK("SstFileManagerImpl::ScheduleFileDeletion",
const_cast<std::string*>(&file_path));
return delete_scheduler_.DeleteFile(file_path, path_to_sync,
force_bg);
return delete_scheduler_.DeleteFile(file_path, path_to_sync, force_bg);
}
void SstFileManagerImpl::WaitForEmptyTrash() {

@ -9,10 +9,9 @@
#include <string>
#include "port/port.h"
#include "db/compaction/compaction.h"
#include "file/delete_scheduler.h"
#include "port/port.h"
#include "rocksdb/sst_file_manager.h"
namespace ROCKSDB_NAMESPACE {

Loading…
Cancel
Save