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
main
Siying Dong 7 years ago committed by Facebook Github Bot
parent 8425c8bd4d
commit a5e851e113
  1. 2
      db/db_universal_compaction_test.cc
  2. 28
      java/rocksjni/transaction.cc
  3. 7
      java/src/test/java/org/rocksdb/AbstractTransactionTest.java
  4. 4
      port/win/win_jemalloc.cc
  5. 33
      table/block_based_table_builder.cc
  6. 10
      table/table_test.cc
  7. 24
      tools/db_bench_tool.cc
  8. 9
      util/status.cc
  9. 3
      util/thread_local.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(

@ -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<std::vector<rocksdb::Status>(
void free_parts(
JNIEnv* env,
std::vector<std::tuple<jbyteArray, jbyte*, jobject>> &parts_to_free) {
for (auto &value : parts_to_free) {
std::vector<std::tuple<jbyteArray, jbyte*, jobject>>& 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<char*>(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<rocksdb::Status(const rocksdb::SliceParts&)>
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<rocksdb::Slice> key_parts;
std::vector<std::tuple<jbyteArray, jbyte*, jobject>> jkey_parts_to_free;
@ -868,12 +867,13 @@ void txn_write_k_parts_helper(JNIEnv* env,
jkey_parts_to_free.push_back(std::tuple<jbyteArray, jbyte*, jobject>(
jba_key_part, jkey_part, jobj_key_part));
key_parts.push_back(rocksdb::Slice(reinterpret_cast<char*>(jkey_part), jkey_part_len));
key_parts.push_back(
rocksdb::Slice(reinterpret_cast<char*>(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);

@ -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);
}
}

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

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

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

@ -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<int64_t>(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());
}
}

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

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

Loading…
Cancel
Save