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. 16
      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, Status DeleteScheduler::DeleteFile(const std::string& file_path,
const std::string& dir_to_sync, const std::string& dir_to_sync,
const bool force_bg) { 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() > total_trash_size_.load() >
sst_file_manager_->GetTotalSize() * max_trash_db_ratio_.load())) { sst_file_manager_->GetTotalSize() * max_trash_db_ratio_.load())) {
// Rate limiting is disabled or trash size makes up more than // 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 (my_status.ok()) {
if (num_hard_links == 1) { if (num_hard_links == 1) {
std::unique_ptr<FSWritableFile> wf; std::unique_ptr<FSWritableFile> wf;
my_status = fs_->ReopenWritableFile(path_in_trash, FileOptions(), my_status = fs_->ReopenWritableFile(path_in_trash, FileOptions(), &wf,
&wf, nullptr); nullptr);
if (my_status.ok()) { if (my_status.ok()) {
my_status = wf->Truncate(file_size - bytes_max_delete_chunk_, my_status = wf->Truncate(file_size - bytes_max_delete_chunk_,
IOOptions(), nullptr); IOOptions(), nullptr);

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

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

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

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

@ -1619,8 +1619,7 @@ namespace {
// Check stats to make sure async prefetch is done. // Check stats to make sure async prefetch is done.
{ {
HistogramData async_read_bytes; HistogramData async_read_bytes;
options.statistics->histogramData(ASYNC_READ_BYTES, options.statistics->histogramData(ASYNC_READ_BYTES, &async_read_bytes);
&async_read_bytes);
HistogramData prefetched_bytes_discarded; HistogramData prefetched_bytes_discarded;
options.statistics->histogramData(PREFETCHED_BYTES_DISCARDED, options.statistics->histogramData(PREFETCHED_BYTES_DISCARDED,
&prefetched_bytes_discarded); &prefetched_bytes_discarded);
@ -1761,8 +1760,7 @@ namespace {
// Check stats to make sure async prefetch is done. // Check stats to make sure async prefetch is done.
{ {
HistogramData async_read_bytes; HistogramData async_read_bytes;
options.statistics->histogramData(ASYNC_READ_BYTES, options.statistics->histogramData(ASYNC_READ_BYTES, &async_read_bytes);
&async_read_bytes);
// Not all platforms support iouring. In that case, ReadAsync in posix // Not all platforms support iouring. In that case, ReadAsync in posix
// won't submit async requests. // won't submit async requests.
@ -1796,8 +1794,7 @@ namespace {
// Check stats to make sure async prefetch is done. // Check stats to make sure async prefetch is done.
{ {
HistogramData async_read_bytes; HistogramData async_read_bytes;
options.statistics->histogramData(ASYNC_READ_BYTES, options.statistics->histogramData(ASYNC_READ_BYTES, &async_read_bytes);
&async_read_bytes);
HistogramData prefetched_bytes_discarded; HistogramData prefetched_bytes_discarded;
options.statistics->histogramData(PREFETCHED_BYTES_DISCARDED, options.statistics->histogramData(PREFETCHED_BYTES_DISCARDED,
&prefetched_bytes_discarded); &prefetched_bytes_discarded);
@ -1899,8 +1896,7 @@ namespace {
ASSERT_OK(options.statistics->Reset()); ASSERT_OK(options.statistics->Reset());
// Each block contains around 4 keys. // Each block contains around 4 keys.
auto iter = std::unique_ptr<Iterator>(db_->NewIterator(ro)); auto iter = std::unique_ptr<Iterator>(db_->NewIterator(ro));
iter->Seek( iter->Seek(BuildKey(0)); // Prefetch data because of seek parallelization.
BuildKey(0)); // Prefetch data because of seek parallelization.
ASSERT_TRUE(iter->Valid()); ASSERT_TRUE(iter->Valid());
iter->Next(); iter->Next();
ASSERT_TRUE(iter->Valid()); ASSERT_TRUE(iter->Valid());
@ -2033,8 +2029,8 @@ namespace {
std::unique_ptr<TraceWriter> trace_writer; std::unique_ptr<TraceWriter> trace_writer;
std::string trace_file_path = dbname_ + "/io_trace_file"; std::string trace_file_path = dbname_ + "/io_trace_file";
ASSERT_OK(NewFileTraceWriter(env_, EnvOptions(), trace_file_path, ASSERT_OK(
&trace_writer)); NewFileTraceWriter(env_, EnvOptions(), trace_file_path, &trace_writer));
ASSERT_OK(db_->StartIOTrace(trace_opt, std::move(trace_writer))); ASSERT_OK(db_->StartIOTrace(trace_opt, std::move(trace_writer)));
ASSERT_OK(options.statistics->Reset()); ASSERT_OK(options.statistics->Reset());

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

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

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

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

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

Loading…
Cancel
Save