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
This commit is contained in:
akankshamahajan 2022-10-24 18:34:52 -07:00 committed by Facebook GitHub Bot
parent 935aae3bcf
commit 671753c43d
13 changed files with 556 additions and 568 deletions

View File

@ -61,9 +61,10 @@ 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 &&
total_trash_size_.load() >
sst_file_manager_->GetTotalSize() * max_trash_db_ratio_.load())) {
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
// max_trash_db_ratio_ (default 25%) of the total DB size
TEST_SYNC_POINT("DeleteScheduler::DeleteFile");
@ -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);

View File

@ -14,7 +14,6 @@
#include "monitoring/instrumented_mutex.h"
#include "port/port.h"
#include "rocksdb/status.h"
namespace ROCKSDB_NAMESPACE {
@ -54,7 +53,7 @@ class DeleteScheduler {
// set, it forces the file to always be deleted in the background thread,
// except when rate limiting is disabled
Status DeleteFile(const std::string& fname, const std::string& dir_to_sync,
const bool force_bg = false);
const bool force_bg = false);
// Wait for all files being deleteing in the background to finish or for
// destructor to be called.
@ -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) {

View File

@ -136,7 +136,7 @@ TEST_F(DeleteSchedulerTest, BasicRateLimiting) {
EXPECT_EQ(dummy_files_dirs_[0], *dir);
});
int num_files = 100; // 100 files
int num_files = 100; // 100 files
uint64_t file_size = 1024; // every file is 1 kb
std::vector<uint64_t> delete_kbs_per_sec = {512, 200, 100, 50, 25};
@ -249,7 +249,7 @@ TEST_F(DeleteSchedulerTest, RateLimitingMultiThreaded) {
[&](void* arg) { penalties.push_back(*(static_cast<uint64_t*>(arg))); });
int thread_cnt = 10;
int num_files = 10; // 10 files per thread
int num_files = 10; // 10 files per thread
uint64_t file_size = 1024; // every file is 1 kb
std::vector<uint64_t> delete_kbs_per_sec = {512, 200, 100, 50, 25};
@ -591,8 +591,7 @@ TEST_F(DeleteSchedulerTest, DISABLED_DynamicRateLimiting1) {
rate_bytes_per_sec_ = 0; // Disable rate limiting initially
NewDeleteScheduler();
int num_files = 10; // 10 files
int num_files = 10; // 10 files
uint64_t file_size = 1024; // every file is 1 kb
std::vector<int64_t> delete_kbs_per_sec = {512, 200, 0, 100, 50, -2, 25};
@ -662,9 +661,9 @@ TEST_F(DeleteSchedulerTest, ImmediateDeleteOn25PercDBSize) {
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
int num_files = 100; // 100 files
uint64_t file_size = 1024 * 10; // 100 KB as a file size
rate_bytes_per_sec_ = 1; // 1 byte per sec (very slow trash delete)
int num_files = 100; // 100 files
uint64_t file_size = 1024 * 10; // 100 KB as a file size
rate_bytes_per_sec_ = 1; // 1 byte per sec (very slow trash delete)
NewDeleteScheduler();
delete_scheduler_->SetMaxTrashDBRatio(0.25);

View File

@ -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"

View File

@ -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,9 +153,10 @@ 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
"(path "
"%" PRIu32 ")",
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);
}
@ -370,7 +369,7 @@ bool ParseFileName(const std::string& fname, uint64_t* number,
*log_type = kAliveLogFile;
}
} else if (archive_dir_found) {
return false; // Archive dir can contain only log files
return false; // Archive dir can contain only log files
} else if (suffix == Slice(kRocksDbTFileExt) ||
suffix == Slice(kLevelDbTFileExt)) {
*type = kTableFile;

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -248,7 +248,7 @@ size_t End(const FSReadRequest& r) {
FSReadRequest Align(const FSReadRequest& r, size_t alignment) {
FSReadRequest req;
req.offset = static_cast<uint64_t>(
TruncateToPageBoundary(alignment, static_cast<size_t>(r.offset)));
TruncateToPageBoundary(alignment, static_cast<size_t>(r.offset)));
req.len = Roundup(End(r), alignment) - req.offset;
req.scratch = nullptr;
return req;

View File

@ -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.

View File

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

View File

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

View File

@ -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,
const bool force_bg) {
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() {

View File

@ -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 {