From a5e851e113ba66fd82b651fd0d3b13750fb75a55 Mon Sep 17 00:00:00 2001 From: Siying Dong Date: Fri, 20 Jul 2018 14:34:07 -0700 Subject: [PATCH] Reformatting some recent changes (#4161) Summary: Lint is not happy with some new code recently committed. Format them. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4161 Differential Revision: D8940582 Pulled By: siying fbshipit-source-id: c9b43b1ef8c88b5e923911058b44eb77234b36b7 --- db/db_universal_compaction_test.cc | 2 +- java/rocksjni/transaction.cc | 28 ++++++++-------- .../org/rocksdb/AbstractTransactionTest.java | 7 ++-- port/win/win_jemalloc.cc | 4 +-- table/block_based_table_builder.cc | 33 +++++++++++-------- table/table_test.cc | 10 +++--- tools/db_bench_tool.cc | 24 +++++++------- util/status.cc | 9 +++-- util/thread_local.cc | 3 +- 9 files changed, 62 insertions(+), 58 deletions(-) diff --git a/db/db_universal_compaction_test.cc b/db/db_universal_compaction_test.cc index 00303b056..4f6a1aead 100644 --- a/db/db_universal_compaction_test.cc +++ b/db/db_universal_compaction_test.cc @@ -1824,7 +1824,7 @@ TEST_P(DBTestUniversalCompaction, FinalSortedRunCompactFilesConflict) { port::Thread compact_files_thread([&]() { ASSERT_OK(dbfull()->CompactFiles(CompactionOptions(), default_cfh, - {first_sst_filename}, num_levels_ - 1)); + {first_sst_filename}, num_levels_ - 1)); }); TEST_SYNC_POINT( diff --git a/java/rocksjni/transaction.cc b/java/rocksjni/transaction.cc index 62bf9e922..43be09560 100644 --- a/java/rocksjni/transaction.cc +++ b/java/rocksjni/transaction.cc @@ -18,7 +18,8 @@ using namespace std::placeholders; #if defined(_MSC_VER) #pragma warning(push) -#pragma warning(disable : 4503) // identifier' : decorated name length exceeded, name was truncated +#pragma warning(disable : 4503) // identifier' : decorated name length + // exceeded, name was truncated #endif /* @@ -271,8 +272,8 @@ typedef std::function( void free_parts( JNIEnv* env, - std::vector> &parts_to_free) { - for (auto &value : parts_to_free) { + std::vector>& parts_to_free) { + for (auto& value : parts_to_free) { jobject jk; jbyteArray jk_ba; jbyte* jk_val; @@ -671,10 +672,10 @@ void txn_write_kv_parts_helper(JNIEnv* env, return; } - jparts_to_free.push_back(std::make_tuple( - jba_key_part, jkey_part, jobj_key_part)); - jparts_to_free.push_back(std::make_tuple( - jba_value_part, jvalue_part, jobj_value_part)); + jparts_to_free.push_back( + std::make_tuple(jba_key_part, jkey_part, jobj_key_part)); + jparts_to_free.push_back( + std::make_tuple(jba_value_part, jvalue_part, jobj_value_part)); key_parts.push_back( rocksdb::Slice(reinterpret_cast(jkey_part), jkey_part_len)); @@ -684,8 +685,8 @@ void txn_write_kv_parts_helper(JNIEnv* env, // call the write_multi function rocksdb::Status s = fn_write_kv_parts( - rocksdb::SliceParts(key_parts.data(), (int)key_parts.size()), - rocksdb::SliceParts(value_parts.data(), (int)value_parts.size())); + rocksdb::SliceParts(key_parts.data(), (int)key_parts.size()), + rocksdb::SliceParts(value_parts.data(), (int)value_parts.size())); // cleanup temporary memory free_parts(env, jparts_to_free); @@ -830,13 +831,11 @@ void Java_org_rocksdb_Transaction_delete__J_3BI(JNIEnv* env, jobject /*jobj*/, typedef std::function FnWriteKParts; - // TODO(AR) consider refactoring to share this between here and rocksjni.cc void txn_write_k_parts_helper(JNIEnv* env, const FnWriteKParts& fn_write_k_parts, const jobjectArray& jkey_parts, const jint& jkey_parts_len) { - std::vector key_parts; std::vector> jkey_parts_to_free; @@ -868,12 +867,13 @@ void txn_write_k_parts_helper(JNIEnv* env, jkey_parts_to_free.push_back(std::tuple( jba_key_part, jkey_part, jobj_key_part)); - key_parts.push_back(rocksdb::Slice(reinterpret_cast(jkey_part), jkey_part_len)); + key_parts.push_back( + rocksdb::Slice(reinterpret_cast(jkey_part), jkey_part_len)); } // call the write_multi function - rocksdb::Status s = - fn_write_k_parts(rocksdb::SliceParts(key_parts.data(), (int)key_parts.size())); + rocksdb::Status s = fn_write_k_parts( + rocksdb::SliceParts(key_parts.data(), (int)key_parts.size())); // cleanup temporary memory free_parts(env, jkey_parts_to_free); diff --git a/java/src/test/java/org/rocksdb/AbstractTransactionTest.java b/java/src/test/java/org/rocksdb/AbstractTransactionTest.java index 3a30b4b22..7cac3015b 100644 --- a/java/src/test/java/org/rocksdb/AbstractTransactionTest.java +++ b/java/src/test/java/org/rocksdb/AbstractTransactionTest.java @@ -686,13 +686,12 @@ public abstract class AbstractTransactionTest { @Test public void elapsedTime() throws RocksDBException, InterruptedException { final long preStartTxnTime = System.currentTimeMillis(); - try(final DBContainer dbContainer = startDb(); - final Transaction txn = dbContainer.beginTransaction()) { + try (final DBContainer dbContainer = startDb(); + final Transaction txn = dbContainer.beginTransaction()) { Thread.sleep(2); final long txnElapsedTime = txn.getElapsedTime(); - assertThat(txnElapsedTime).isLessThan(System.currentTimeMillis() - - preStartTxnTime); + assertThat(txnElapsedTime).isLessThan(System.currentTimeMillis() - preStartTxnTime); assertThat(txnElapsedTime).isGreaterThan(0); } } diff --git a/port/win/win_jemalloc.cc b/port/win/win_jemalloc.cc index fe57c631f..3268a56af 100644 --- a/port/win/win_jemalloc.cc +++ b/port/win/win_jemalloc.cc @@ -43,8 +43,8 @@ void* jemalloc_aligned_alloc(size_t size, size_t alignment) ROCKSDB_NOEXCEPT { return je_aligned_alloc(alignment, size); } void jemalloc_aligned_free(void* p) ROCKSDB_NOEXCEPT { je_free(p); } -} // port -} // rocksdb +} // namespace port +} // namespace rocksdb void* operator new(size_t size) { void* p = je_malloc(size); diff --git a/table/block_based_table_builder.cc b/table/block_based_table_builder.cc index df094ffa2..768fb7566 100644 --- a/table/block_based_table_builder.cc +++ b/table/block_based_table_builder.cc @@ -39,11 +39,11 @@ #include "table/full_filter_block.h" #include "table/table_builder.h" -#include "util/string_util.h" #include "util/coding.h" #include "util/compression.h" #include "util/crc32c.h" #include "util/stop_watch.h" +#include "util/string_util.h" #include "util/xxhash.h" #include "table/index_builder.h" @@ -675,7 +675,8 @@ void BlockBasedTableBuilder::WriteFilterBlock( if (ok() && !empty_filter_block) { Status s = Status::Incomplete(); while (ok() && s.IsIncomplete()) { - Slice filter_content = rep_->filter_builder->Finish(filter_block_handle, &s); + Slice filter_content = + rep_->filter_builder->Finish(filter_block_handle, &s); assert(s.ok() || s.IsIncomplete()); rep_->props.filter_size += filter_content.size(); WriteRawBlock(filter_content, kNoCompression, &filter_block_handle); @@ -752,21 +753,25 @@ void BlockBasedTableBuilder::WritePropertiesBlock( PropertyBlockBuilder property_block_builder; rep_->props.column_family_id = rep_->column_family_id; rep_->props.column_family_name = rep_->column_family_name; - rep_->props.filter_policy_name = rep_->table_options.filter_policy != nullptr - ? rep_->table_options.filter_policy->Name() - : ""; - rep_->props.index_size = rep_->index_builder->EstimatedSize() + kBlockTrailerSize; + rep_->props.filter_policy_name = + rep_->table_options.filter_policy != nullptr + ? rep_->table_options.filter_policy->Name() + : ""; + rep_->props.index_size = + rep_->index_builder->EstimatedSize() + kBlockTrailerSize; rep_->props.comparator_name = rep_->ioptions.user_comparator != nullptr - ? rep_->ioptions.user_comparator->Name() - : "nullptr"; - rep_->props.merge_operator_name = rep_->ioptions.merge_operator != nullptr - ? rep_->ioptions.merge_operator->Name() - : "nullptr"; + ? rep_->ioptions.user_comparator->Name() + : "nullptr"; + rep_->props.merge_operator_name = + rep_->ioptions.merge_operator != nullptr + ? rep_->ioptions.merge_operator->Name() + : "nullptr"; rep_->props.compression_name = CompressionTypeToString(rep_->compression_ctx.type()); - rep_->props.prefix_extractor_name = rep_->moptions.prefix_extractor != nullptr - ? rep_->moptions.prefix_extractor->Name() - : "nullptr"; + rep_->props.prefix_extractor_name = + rep_->moptions.prefix_extractor != nullptr + ? rep_->moptions.prefix_extractor->Name() + : "nullptr"; std::string property_collectors_names = "["; for (size_t i = 0; diff --git a/table/table_test.cc b/table/table_test.cc index 342972973..080e44f00 100644 --- a/table/table_test.cc +++ b/table/table_test.cc @@ -364,7 +364,8 @@ class TableConstructor: public Constructor { TableReaderOptions(ioptions, moptions.prefix_extractor.get(), soptions, internal_comparator, !kSkipFilters, !kImmortal, level_), - std::move(file_reader_), TEST_GetSink()->contents().size(), &table_reader_); + std::move(file_reader_), TEST_GetSink()->contents().size(), + &table_reader_); } virtual InternalIterator* NewIterator( @@ -394,12 +395,11 @@ class TableConstructor: public Constructor { return ioptions.table_factory->NewTableReader( TableReaderOptions(ioptions, moptions.prefix_extractor.get(), soptions, *last_internal_key_), - std::move(file_reader_), TEST_GetSink()->contents().size(), &table_reader_); + std::move(file_reader_), TEST_GetSink()->contents().size(), + &table_reader_); } - virtual TableReader* GetTableReader() { - return table_reader_.get(); - } + virtual TableReader* GetTableReader() { return table_reader_.get(); } virtual bool AnywayDeleteIterator() const override { return convert_to_internal_key_; diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index 95af4908b..7f8676e8d 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -4178,8 +4178,8 @@ void VerifyDBFromDB(std::string& truth_db_name) { delete iter; thread->stats.AddBytes(bytes); if (FLAGS_perf_level > rocksdb::PerfLevel::kDisable) { - thread->stats.AddMessage( - std::string("PERF_CONTEXT:\n") + get_perf_context()->ToString()); + thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + + get_perf_context()->ToString()); } } @@ -4261,8 +4261,8 @@ void VerifyDBFromDB(std::string& truth_db_name) { thread->stats.AddMessage(msg); if (FLAGS_perf_level > rocksdb::PerfLevel::kDisable) { - thread->stats.AddMessage( - std::string("PERF_CONTEXT:\n") + get_perf_context()->ToString()); + thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + + get_perf_context()->ToString()); } } @@ -4340,8 +4340,8 @@ void VerifyDBFromDB(std::string& truth_db_name) { thread->stats.AddMessage(msg); if (FLAGS_perf_level > rocksdb::PerfLevel::kDisable) { - thread->stats.AddMessage( - std::string("PERF_CONTEXT:\n") + get_perf_context()->ToString()); + thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + + get_perf_context()->ToString()); } } @@ -4498,8 +4498,8 @@ void VerifyDBFromDB(std::string& truth_db_name) { thread->stats.AddBytes(bytes); thread->stats.AddMessage(msg); if (FLAGS_perf_level > rocksdb::PerfLevel::kDisable) { - thread->stats.AddMessage( - std::string("PERF_CONTEXT:\n") + get_perf_context()->ToString()); + thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + + get_perf_context()->ToString()); } } @@ -5250,8 +5250,8 @@ void VerifyDBFromDB(std::string& truth_db_name) { thread->stats.AddMessage(msg); if (FLAGS_perf_level > rocksdb::PerfLevel::kDisable) { - thread->stats.AddMessage( - std::string("PERF_CONTEXT:\n") + get_perf_context()->ToString()); + thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + + get_perf_context()->ToString()); } thread->stats.AddBytes(static_cast(inserter.GetBytesInserted())); } @@ -5413,8 +5413,8 @@ void VerifyDBFromDB(std::string& truth_db_name) { thread->stats.AddBytes(bytes); thread->stats.AddMessage(msg); if (FLAGS_perf_level > rocksdb::PerfLevel::kDisable) { - thread->stats.AddMessage( - std::string("PERF_CONTEXT:\n") + get_perf_context()->ToString()); + thread->stats.AddMessage(std::string("PERF_CONTEXT:\n") + + get_perf_context()->ToString()); } } diff --git a/util/status.cc b/util/status.cc index 8dc20f836..c58e21f26 100644 --- a/util/status.cc +++ b/util/status.cc @@ -19,8 +19,7 @@ namespace rocksdb { const char* Status::CopyState(const char* state) { #ifdef OS_WIN - const size_t cch = - std::strlen(state) + 1; // +1 for the null terminator + const size_t cch = std::strlen(state) + 1; // +1 for the null terminator char* result = new char[cch]; errno_t ret; ret = strncpy_s(result, cch, state, cch - 1); @@ -28,13 +27,13 @@ const char* Status::CopyState(const char* state) { assert(ret == 0); return result; #else - const size_t cch = - std::strlen(state) + 1; // +1 for the null terminator + const size_t cch = std::strlen(state) + 1; // +1 for the null terminator return std::strncpy(new char[cch], state, cch); #endif } -Status::Status(Code _code, SubCode _subcode, const Slice& msg, const Slice& msg2) +Status::Status(Code _code, SubCode _subcode, const Slice& msg, + const Slice& msg2) : code_(_code), subcode_(_subcode), sev_(kNoError) { assert(code_ != kOk); assert(subcode_ != kMaxSubCode); diff --git a/util/thread_local.cc b/util/thread_local.cc index 9b901f6b1..dea2002a0 100644 --- a/util/thread_local.cc +++ b/util/thread_local.cc @@ -184,7 +184,8 @@ pthread_key_t thread_local_key = pthread_key_t (-1); void NTAPI WinOnThreadExit(PVOID module, DWORD reason, PVOID reserved) { // We decided to punt on PROCESS_EXIT if (DLL_THREAD_DETACH == reason) { - if (thread_local_key != pthread_key_t(-1) && thread_local_inclass_routine != nullptr) { + if (thread_local_key != pthread_key_t(-1) && + thread_local_inclass_routine != nullptr) { void* tls = TlsGetValue(thread_local_key); if (tls != nullptr) { thread_local_inclass_routine(tls);