tidy: enable rule for constant naming This enables the rule that constants should be named kFooBar and fixes the cases where we didn't adhere to this. The fixes were started using clang-tidy --fix, but it wasn't very good at finding all references, so I did some by-hand tweaking to get it to compile after that.
I left a few aberrations in gutil, etc, but this should be at least a good cleanup. Change-Id: I7971659ef3152580d44d6ddfb18be7ebf41052c7 Reviewed-on: http://gerrit.cloudera.org:8080/7158 Reviewed-by: Adar Dembo <[email protected]> Tested-by: Kudu Jenkins Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/e719b5ef Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/e719b5ef Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/e719b5ef Branch: refs/heads/master Commit: e719b5eff2a47f61f9e6ee1f18d2055247f45847 Parents: 850ebef Author: Todd Lipcon <[email protected]> Authored: Mon Jun 12 15:03:49 2017 -0700 Committer: Todd Lipcon <[email protected]> Committed: Mon Jun 12 23:12:25 2017 +0000 ---------------------------------------------------------------------- src/kudu/.clang-tidy | 4 ++ src/kudu/cfile/type_encodings.cc | 6 +-- src/kudu/client/meta_cache.cc | 6 +-- src/kudu/fs/log_block_manager.cc | 8 ++-- src/kudu/fs/log_block_manager.h | 4 +- src/kudu/gutil/strings/escaping.cc | 4 +- src/kudu/gutil/strings/substitute.cc | 4 +- src/kudu/gutil/strings/substitute.h | 42 ++++++++++---------- src/kudu/integration-tests/all_types-itest.cc | 24 +++++------ src/kudu/master/master.cc | 2 +- src/kudu/rpc/protoc-gen-krpc.cc | 8 ++-- src/kudu/rpc/request_tracker-test.cc | 4 +- src/kudu/rpc/request_tracker.cc | 4 +- src/kudu/rpc/request_tracker.h | 4 +- src/kudu/rpc/retriable_rpc.h | 10 ++--- src/kudu/security/ca/cert_management.cc | 4 +- src/kudu/security/cert.cc | 2 +- src/kudu/security/crypto.cc | 22 +++++----- src/kudu/security/openssl_util.h | 28 ++++++------- src/kudu/security/openssl_util_bio.h | 10 ++--- src/kudu/security/tls_context.cc | 4 +- src/kudu/server/pprof-path-handlers.cc | 8 ++-- src/kudu/server/webserver.cc | 12 +++--- .../tablet/all_types-scan-correctness-test.cc | 22 +++++----- src/kudu/tablet/cbtree-test.cc | 10 ++--- src/kudu/tablet/concurrent_btree.h | 14 +++---- src/kudu/tserver/tablet_server.cc | 2 +- src/kudu/util/debug/trace_event_impl.cc | 20 +++++----- src/kudu/util/maintenance_manager.cc | 2 +- src/kudu/util/maintenance_manager.h | 2 +- src/kudu/util/mem_tracker-test.cc | 4 +- src/kudu/util/os-util.cc | 26 ++++++------ src/kudu/util/process_memory.cc | 4 +- src/kudu/util/rle-test.cc | 12 +++--- src/kudu/util/trace.h | 20 +++++----- 35 files changed, 183 insertions(+), 179 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/.clang-tidy ---------------------------------------------------------------------- diff --git a/src/kudu/.clang-tidy b/src/kudu/.clang-tidy index de0a477..e94a29d 100644 --- a/src/kudu/.clang-tidy +++ b/src/kudu/.clang-tidy @@ -29,3 +29,7 @@ CheckOptions: value: lower_case - key: readability-identifier-naming.InlineNamespaceCase value: lower_case + - key: readability-identifier-naming.GlobalConstantCase + value: CamelCase + - key: readability-identifier-naming.GlobalConstantPrefix + value: 'k' http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/cfile/type_encodings.cc ---------------------------------------------------------------------- diff --git a/src/kudu/cfile/type_encodings.cc b/src/kudu/cfile/type_encodings.cc index fbb9036..3eae786 100644 --- a/src/kudu/cfile/type_encodings.cc +++ b/src/kudu/cfile/type_encodings.cc @@ -46,8 +46,8 @@ struct DataTypeEncodingTraits {}; template<DataType Type, EncodingType Encoding> struct TypeEncodingTraits : public DataTypeEncodingTraits<Type, Encoding> { - static const DataType type = Type; - static const EncodingType encoding_type = Encoding; + static const DataType kType = Type; + static const EncodingType kEncodingType = Encoding; }; // Generic, fallback, partial specialization that should work for all @@ -185,7 +185,7 @@ struct DataTypeEncodingTraits<IntType, RLE> { template<typename TypeEncodingTraitsClass> TypeEncodingInfo::TypeEncodingInfo(TypeEncodingTraitsClass t) - : encoding_type_(TypeEncodingTraitsClass::encoding_type), + : encoding_type_(TypeEncodingTraitsClass::kEncodingType), create_builder_func_(TypeEncodingTraitsClass::CreateBlockBuilder), create_decoder_func_(TypeEncodingTraitsClass::CreateBlockDecoder) { } http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/client/meta_cache.cc ---------------------------------------------------------------------- diff --git a/src/kudu/client/meta_cache.cc b/src/kudu/client/meta_cache.cc index b58f45c..398a395 100644 --- a/src/kudu/client/meta_cache.cc +++ b/src/kudu/client/meta_cache.cc @@ -71,7 +71,7 @@ namespace client { namespace internal { namespace { -const int MAX_RETURNED_TABLE_LOCATIONS = 10; +const int kMaxReturnedTableLocations = 10; } // anonymous namespace //////////////////////////////////////////////////////////// @@ -651,7 +651,7 @@ void LookupRpc::SendRpc() { // Fill out the request. req_.mutable_table()->set_table_id(table_->id()); req_.set_partition_key_start(partition_key_); - req_.set_max_returned_locations(MAX_RETURNED_TABLE_LOCATIONS); + req_.set_max_returned_locations(kMaxReturnedTableLocations); // The end partition key is left unset intentionally so that we'll prefetch // some additional tablets. @@ -910,7 +910,7 @@ Status MetaCache::ProcessLookupResponse(const LookupRpc& rpc, InsertOrDie(&tablets_by_key, tablet_lower_bound, std::move(entry)); } - if (!last_upper_bound.empty() && tablet_locations.size() < MAX_RETURNED_TABLE_LOCATIONS) { + if (!last_upper_bound.empty() && tablet_locations.size() < kMaxReturnedTableLocations) { // There is a non-covered range between the last tablet and the end of the // partition key space, such as F. http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/fs/log_block_manager.cc ---------------------------------------------------------------------- diff --git a/src/kudu/fs/log_block_manager.cc b/src/kudu/fs/log_block_manager.cc index 8ca0a16..9565b5f 100644 --- a/src/kudu/fs/log_block_manager.cc +++ b/src/kudu/fs/log_block_manager.cc @@ -1382,7 +1382,7 @@ static const char* kBlockManagerType = "log"; // These values were arrived at via experimentation. See commit 4923a74 for // more details. -const map<int64_t, int64_t> LogBlockManager::per_fs_block_size_block_limits({ +const map<int64_t, int64_t> LogBlockManager::kPerFsBlockSizeBlockLimits({ { 1024, 673 }, { 2048, 1353 }, { 4096, 2721 }}); @@ -1477,7 +1477,7 @@ Status LogBlockManager::Open(FsReport* report) { uint64_t fs_block_size = dd->instance()->metadata()->filesystem_block_size_bytes(); bool untested_block_size = - !ContainsKey(per_fs_block_size_block_limits, fs_block_size); + !ContainsKey(kPerFsBlockSizeBlockLimits, fs_block_size); string msg = Substitute( "Data dir $0 is on an ext4 filesystem vulnerable to KUDU-1508 " "with $1block size $2", dd->dir(), @@ -2368,7 +2368,7 @@ bool LogBlockManager::IsBuggyEl6Kernel(const string& kernel_release) { } int64_t LogBlockManager::LookupBlockLimit(int64_t fs_block_size) { - const int64_t* limit = FindFloorOrNull(per_fs_block_size_block_limits, + const int64_t* limit = FindFloorOrNull(kPerFsBlockSizeBlockLimits, fs_block_size); if (limit) { return *limit; @@ -2376,7 +2376,7 @@ int64_t LogBlockManager::LookupBlockLimit(int64_t fs_block_size) { // Block size must have been less than the very first key. Return the // first recorded entry and hope for the best. - return per_fs_block_size_block_limits.begin()->second; + return kPerFsBlockSizeBlockLimits.begin()->second; } } // namespace fs http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/fs/log_block_manager.h ---------------------------------------------------------------------- diff --git a/src/kudu/fs/log_block_manager.h b/src/kudu/fs/log_block_manager.h index eead3d2..ad6b7cf 100644 --- a/src/kudu/fs/log_block_manager.h +++ b/src/kudu/fs/log_block_manager.h @@ -338,7 +338,7 @@ class LogBlockManager : public BlockManager { // Returns whether the given kernel release is vulnerable to KUDU-1508. static bool IsBuggyEl6Kernel(const std::string& kernel_release); - // Finds an appropriate block limit from 'per_fs_block_size_block_limits' + // Finds an appropriate block limit from 'kPerFsBlockSizeBlockLimits' // using the given filesystem block size. static int64_t LookupBlockLimit(int64_t fs_block_size); @@ -346,7 +346,7 @@ class LogBlockManager : public BlockManager { // For kernels affected by KUDU-1508, tracks a known good upper bound on the // number of blocks per container, given a particular filesystem block size. - static const std::map<int64_t, int64_t> per_fs_block_size_block_limits; + static const std::map<int64_t, int64_t> kPerFsBlockSizeBlockLimits; // Tracks memory consumption of any allocations numerous enough to be // interesting (e.g. LogBlocks). http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/gutil/strings/escaping.cc ---------------------------------------------------------------------- diff --git a/src/kudu/gutil/strings/escaping.cc b/src/kudu/gutil/strings/escaping.cc index cf49359..7b03335 100644 --- a/src/kudu/gutil/strings/escaping.cc +++ b/src/kudu/gutil/strings/escaping.cc @@ -1639,7 +1639,7 @@ void TenHexDigitsToEightBase32Digits(const char *in, char *out) { // ---------------------------------------------------------------------- // EscapeFileName / UnescapeFileName // ---------------------------------------------------------------------- -static const Charmap escape_file_name_exceptions( +static const Charmap kEscapeFileNameExceptions( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" // letters "0123456789" // digits "-_."); @@ -1651,7 +1651,7 @@ void EscapeFileName(const StringPiece& src, string* dst) { for (char c : src) { // We do not use "isalpha" because we want the behavior to be // independent of the current locale settings. - if (escape_file_name_exceptions.contains(c)) { + if (kEscapeFileNameExceptions.contains(c)) { dst->push_back(c); } else if (c == '/') { http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/gutil/strings/substitute.cc ---------------------------------------------------------------------- diff --git a/src/kudu/gutil/strings/substitute.cc b/src/kudu/gutil/strings/substitute.cc index 245894b..5e5c12a 100644 --- a/src/kudu/gutil/strings/substitute.cc +++ b/src/kudu/gutil/strings/substitute.cc @@ -13,13 +13,13 @@ namespace strings { using internal::SubstituteArg; -const SubstituteArg SubstituteArg::NoArg; +const SubstituteArg SubstituteArg::kNoArg; // Returns the number of args in arg_array which were passed explicitly // to Substitute(). static int CountSubstituteArgs(const SubstituteArg* const* args_array) { int count = 0; - while (args_array[count] != &SubstituteArg::NoArg) { + while (args_array[count] != &SubstituteArg::kNoArg) { ++count; } return count; http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/gutil/strings/substitute.h ---------------------------------------------------------------------- diff --git a/src/kudu/gutil/strings/substitute.h b/src/kudu/gutil/strings/substitute.h index 0812c3f..2de5960 100644 --- a/src/kudu/gutil/strings/substitute.h +++ b/src/kudu/gutil/strings/substitute.h @@ -131,7 +131,7 @@ class SubstituteArg { inline int size() const { return size_; } // Indicates that no argument was given. - static const SubstituteArg NoArg; + static const SubstituteArg kNoArg; private: inline SubstituteArg() : text_(NULL), size_(-1) {} @@ -158,29 +158,29 @@ char* SubstituteToBuffer(StringPiece format, void SubstituteAndAppend( string* output, StringPiece format, - const internal::SubstituteArg& arg0 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg1 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg2 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg3 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg4 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg5 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg6 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg7 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg8 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg9 = internal::SubstituteArg::NoArg); + const internal::SubstituteArg& arg0 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg1 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg2 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg3 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg4 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg5 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg6 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg7 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg8 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg9 = internal::SubstituteArg::kNoArg); inline string Substitute( StringPiece format, - const internal::SubstituteArg& arg0 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg1 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg2 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg3 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg4 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg5 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg6 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg7 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg8 = internal::SubstituteArg::NoArg, - const internal::SubstituteArg& arg9 = internal::SubstituteArg::NoArg) { + const internal::SubstituteArg& arg0 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg1 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg2 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg3 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg4 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg5 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg6 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg7 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg8 = internal::SubstituteArg::kNoArg, + const internal::SubstituteArg& arg9 = internal::SubstituteArg::kNoArg) { string result; SubstituteAndAppend(&result, format, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/integration-tests/all_types-itest.cc ---------------------------------------------------------------------- diff --git a/src/kudu/integration-tests/all_types-itest.cc b/src/kudu/integration-tests/all_types-itest.cc index cb3147e..b5e5ac7 100644 --- a/src/kudu/integration-tests/all_types-itest.cc +++ b/src/kudu/integration-tests/all_types-itest.cc @@ -37,7 +37,7 @@ using sp::shared_ptr; static const int kNumTabletServers = 3; static const int kNumTablets = 3; -static const int KMaxBatchSize = 8 * 1024 * 1024; +static const int kMaxBatchSize = 8 * 1024 * 1024; template<typename KeyTypeWrapper> struct SliceKeysTestSetup { @@ -50,7 +50,7 @@ struct SliceKeysTestSetup { void AddKeyColumnsToSchema(KuduSchemaBuilder* builder) const { builder->AddColumn("key")->Type( - client::FromInternalDataType(KeyTypeWrapper::type))->NotNull()->PrimaryKey(); + client::FromInternalDataType(KeyTypeWrapper::kType))->NotNull()->PrimaryKey(); } // Split points are calculated by equally partitioning the int64_t key space and then @@ -67,7 +67,7 @@ struct SliceKeysTestSetup { for (string val : splits) { Slice slice(val); KuduPartialRow* row = schema.NewRow(); - CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::type> >(0, slice)); + CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::kType> >(0, slice)); rows.push_back(row); } return rows; @@ -77,7 +77,7 @@ struct SliceKeysTestSetup { int row_key_num = (split_idx * increment_) + row_idx; string row_key = StringPrintf("%08x", row_key_num); Slice row_key_slice(row_key); - return insert->mutable_row()->SetSliceCopy<TypeTraits<KeyTypeWrapper::type> >(0, + return insert->mutable_row()->SetSliceCopy<TypeTraits<KeyTypeWrapper::kType> >(0, row_key_slice); } @@ -95,7 +95,7 @@ struct SliceKeysTestSetup { Status VerifyRowKey(const KuduRowResult& result, int split_idx, int row_idx) const { Slice row_key; - RETURN_NOT_OK(result.Get<TypeTraits<KeyTypeWrapper::type>>(0, &row_key)); + RETURN_NOT_OK(result.Get<TypeTraits<KeyTypeWrapper::kType>>(0, &row_key)); return VerifyRowKeySlice(row_key, split_idx, row_idx); } @@ -125,7 +125,7 @@ struct SliceKeysTestSetup { template<typename KeyTypeWrapper> struct IntKeysTestSetup { - typedef typename TypeTraits<KeyTypeWrapper::type>::cpp_type CppType; + typedef typename TypeTraits<KeyTypeWrapper::kType>::cpp_type CppType; IntKeysTestSetup() // If CppType is actually bigger than int (e.g. int64_t) casting the max to int @@ -139,7 +139,7 @@ struct IntKeysTestSetup { void AddKeyColumnsToSchema(KuduSchemaBuilder* builder) const { builder->AddColumn("key")->Type( - client::FromInternalDataType(KeyTypeWrapper::type))->NotNull()->PrimaryKey(); + client::FromInternalDataType(KeyTypeWrapper::kType))->NotNull()->PrimaryKey(); } vector<const KuduPartialRow*> GenerateSplitRows(const KuduSchema& schema) const { @@ -151,7 +151,7 @@ struct IntKeysTestSetup { vector<const KuduPartialRow*> rows; for (CppType val : splits) { KuduPartialRow* row = schema.NewRow(); - CHECK_OK(row->Set<TypeTraits<KeyTypeWrapper::type> >(0, val)); + CHECK_OK(row->Set<TypeTraits<KeyTypeWrapper::kType> >(0, val)); rows.push_back(row); } return rows; @@ -159,7 +159,7 @@ struct IntKeysTestSetup { Status GenerateRowKey(KuduInsert* insert, int split_idx, int row_idx) const { CppType val = (split_idx * increment_) + row_idx; - return insert->mutable_row()->Set<TypeTraits<KeyTypeWrapper::type> >(0, val); + return insert->mutable_row()->Set<TypeTraits<KeyTypeWrapper::kType> >(0, val); } Status VerifyIntRowKey(CppType val, int split_idx, int row_idx) const { @@ -173,7 +173,7 @@ struct IntKeysTestSetup { Status VerifyRowKey(const KuduRowResult& result, int split_idx, int row_idx) const { CppType val; - RETURN_NOT_OK(result.Get<TypeTraits<KeyTypeWrapper::type>>(0, &val)); + RETURN_NOT_OK(result.Get<TypeTraits<KeyTypeWrapper::kType>>(0, &val)); return VerifyIntRowKey(val, split_idx, row_idx); } @@ -426,7 +426,7 @@ class AllTypesItest : public KuduTest { } RETURN_NOT_OK(scanner_setup(&scanner)); - RETURN_NOT_OK(scanner.SetBatchSizeBytes(KMaxBatchSize)); + RETURN_NOT_OK(scanner.SetBatchSizeBytes(kMaxBatchSize)); RETURN_NOT_OK(scanner.SetFaultTolerant()); RETURN_NOT_OK(scanner.SetReadMode(KuduScanner::READ_AT_SNAPSHOT)); @@ -476,7 +476,7 @@ class AllTypesItest : public KuduTest { // without leaking DataType. template<DataType KeyType> struct KeyTypeWrapper { - static const DataType type = KeyType; + static const DataType kType = KeyType; }; typedef ::testing::Types<IntKeysTestSetup<KeyTypeWrapper<INT8> >, http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/master/master.cc ---------------------------------------------------------------------- diff --git a/src/kudu/master/master.cc b/src/kudu/master/master.cc index 079bd2d..2d883f6 100644 --- a/src/kudu/master/master.cc +++ b/src/kudu/master/master.cc @@ -89,7 +89,7 @@ Master::Master(const MasterOptions& opts) path_handlers_(new MasterPathHandlers(this)), opts_(opts), registration_initialized_(false), - maintenance_manager_(new MaintenanceManager(MaintenanceManager::DEFAULT_OPTIONS)) { + maintenance_manager_(new MaintenanceManager(MaintenanceManager::kDefaultOptions)) { } Master::~Master() { http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/rpc/protoc-gen-krpc.cc ---------------------------------------------------------------------- diff --git a/src/kudu/rpc/protoc-gen-krpc.cc b/src/kudu/rpc/protoc-gen-krpc.cc index de41aa9..e892897 100644 --- a/src/kudu/rpc/protoc-gen-krpc.cc +++ b/src/kudu/rpc/protoc-gen-krpc.cc @@ -91,7 +91,7 @@ class Substituter { // NameInfo contains information about the output names. class FileSubstitutions : public Substituter { public: - static const std::string PROTO_EXTENSION; + static const std::string kProtoExtension; Status Init(const FileDescriptor *file) { string path = file->name(); @@ -99,9 +99,9 @@ class FileSubstitutions : public Substituter { // Initialize path_ // If path = /foo/bar/baz_stuff.proto, path_ = /foo/bar/baz_stuff - if (!TryStripSuffixString(path, PROTO_EXTENSION, &path_no_extension_)) { + if (!TryStripSuffixString(path, kProtoExtension, &path_no_extension_)) { return Status::InvalidArgument("file name " + path + - " did not end in " + PROTO_EXTENSION); + " did not end in " + kProtoExtension); } map_["path_no_extension"] = path_no_extension_; @@ -183,7 +183,7 @@ class FileSubstitutions : public Substituter { map<string, string> map_; }; -const std::string FileSubstitutions::PROTO_EXTENSION(".proto"); +const std::string FileSubstitutions::kProtoExtension(".proto"); class MethodSubstitutions : public Substituter { public: http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/rpc/request_tracker-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/rpc/request_tracker-test.cc b/src/kudu/rpc/request_tracker-test.cc index 89ea8a2..f39e131 100644 --- a/src/kudu/rpc/request_tracker-test.cc +++ b/src/kudu/rpc/request_tracker-test.cc @@ -33,7 +33,7 @@ TEST(RequestTrackerTest, TestSequenceNumberGeneration) { // A new tracker should have no incomplete RPCs RequestTracker::SequenceNumber seq_no = tracker_->FirstIncomplete(); - ASSERT_EQ(seq_no, RequestTracker::NO_SEQ_NO); + ASSERT_EQ(seq_no, RequestTracker::kNoSeqNo); vector<RequestTracker::SequenceNumber> generated_seq_nos; @@ -75,7 +75,7 @@ TEST(RequestTrackerTest, TestSequenceNumberGeneration) { tracker_->RpcCompleted(seq_no); } - ASSERT_EQ(tracker_->FirstIncomplete(), RequestTracker::NO_SEQ_NO); + ASSERT_EQ(tracker_->FirstIncomplete(), RequestTracker::kNoSeqNo); } } // namespace rpc http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/rpc/request_tracker.cc ---------------------------------------------------------------------- diff --git a/src/kudu/rpc/request_tracker.cc b/src/kudu/rpc/request_tracker.cc index 1958664..84a445e 100644 --- a/src/kudu/rpc/request_tracker.cc +++ b/src/kudu/rpc/request_tracker.cc @@ -24,7 +24,7 @@ namespace kudu { namespace rpc { -const RequestTracker::SequenceNumber RequestTracker::NO_SEQ_NO = -1; +const RequestTracker::SequenceNumber RequestTracker::kNoSeqNo = -1; RequestTracker::RequestTracker(const string& client_id) : client_id_(client_id), @@ -40,7 +40,7 @@ Status RequestTracker::NewSeqNo(SequenceNumber* seq_no) { RequestTracker::SequenceNumber RequestTracker::FirstIncomplete() { std::lock_guard<simple_spinlock> l(lock_); - if (incomplete_rpcs_.empty()) return NO_SEQ_NO; + if (incomplete_rpcs_.empty()) return kNoSeqNo; return *incomplete_rpcs_.begin(); } http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/rpc/request_tracker.h ---------------------------------------------------------------------- diff --git a/src/kudu/rpc/request_tracker.h b/src/kudu/rpc/request_tracker.h index 99f8d6c..9698d58 100644 --- a/src/kudu/rpc/request_tracker.h +++ b/src/kudu/rpc/request_tracker.h @@ -48,7 +48,7 @@ namespace rpc { class RequestTracker : public RefCountedThreadSafe<RequestTracker> { public: typedef int64_t SequenceNumber; - static const RequestTracker::SequenceNumber NO_SEQ_NO; + static const RequestTracker::SequenceNumber kNoSeqNo; explicit RequestTracker(const std::string& client_id); // Creates a new, unique, sequence number. @@ -59,7 +59,7 @@ class RequestTracker : public RefCountedThreadSafe<RequestTracker> { Status NewSeqNo(SequenceNumber* seq_no); // Returns the sequence number of the first incomplete RPC. - // If there is no incomplete RPC returns NO_SEQ_NO. + // If there is no incomplete RPC returns kNoSeqNo. SequenceNumber FirstIncomplete(); // Marks the rpc with 'seq_no' as completed. http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/rpc/retriable_rpc.h ---------------------------------------------------------------------- diff --git a/src/kudu/rpc/retriable_rpc.h b/src/kudu/rpc/retriable_rpc.h index c896027..897d7a7 100644 --- a/src/kudu/rpc/retriable_rpc.h +++ b/src/kudu/rpc/retriable_rpc.h @@ -56,11 +56,11 @@ class RetriableRpc : public Rpc { : Rpc(deadline, std::move(messenger)), server_picker_(server_picker), request_tracker_(request_tracker), - sequence_number_(RequestTracker::NO_SEQ_NO), + sequence_number_(RequestTracker::kNoSeqNo), num_attempts_(0) {} virtual ~RetriableRpc() { - DCHECK_EQ(sequence_number_, RequestTracker::NO_SEQ_NO); + DCHECK_EQ(sequence_number_, RequestTracker::kNoSeqNo); } // Performs server lookup/initialization. @@ -138,7 +138,7 @@ class RetriableRpc : public Rpc { template <class Server, class RequestPB, class ResponsePB> void RetriableRpc<Server, RequestPB, ResponsePB>::SendRpc() { - if (sequence_number_ == RequestTracker::NO_SEQ_NO) { + if (sequence_number_ == RequestTracker::kNoSeqNo) { CHECK_OK(request_tracker_->NewSeqNo(&sequence_number_)); } server_picker_->PickLeader(Bind(&RetriableRpc::ReplicaFoundCb, @@ -237,10 +237,10 @@ bool RetriableRpc<Server, RequestPB, ResponsePB>::RetryIfNeeded( template <class Server, class RequestPB, class ResponsePB> void RetriableRpc<Server, RequestPB, ResponsePB>::FinishInternal() { - // Mark the RPC as completed and set the sequence number to NO_SEQ_NO to make + // Mark the RPC as completed and set the sequence number to kNoSeqNo to make // sure we're in the appropriate state before destruction. request_tracker_->RpcCompleted(sequence_number_); - sequence_number_ = RequestTracker::NO_SEQ_NO; + sequence_number_ = RequestTracker::kNoSeqNo; } template <class Server, class RequestPB, class ResponsePB> http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/security/ca/cert_management.cc ---------------------------------------------------------------------- diff --git a/src/kudu/security/ca/cert_management.cc b/src/kudu/security/ca/cert_management.cc index a6d7f7b..c63eb10 100644 --- a/src/kudu/security/ca/cert_management.cc +++ b/src/kudu/security/ca/cert_management.cc @@ -52,10 +52,10 @@ namespace kudu { namespace security { template<> struct SslTypeTraits<ASN1_INTEGER> { - static constexpr auto free = &ASN1_INTEGER_free; + static constexpr auto kFreeFunc = &ASN1_INTEGER_free; }; template<> struct SslTypeTraits<BIGNUM> { - static constexpr auto free = &BN_free; + static constexpr auto kFreeFunc = &BN_free; }; namespace ca { http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/security/cert.cc ---------------------------------------------------------------------- diff --git a/src/kudu/security/cert.cc b/src/kudu/security/cert.cc index fa4c753..dabf2d3 100644 --- a/src/kudu/security/cert.cc +++ b/src/kudu/security/cert.cc @@ -39,7 +39,7 @@ namespace kudu { namespace security { template<> struct SslTypeTraits<GENERAL_NAMES> { - static constexpr auto free = &GENERAL_NAMES_free; + static constexpr auto kFreeFunc = &GENERAL_NAMES_free; }; // This OID is generated via the UUID method. http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/security/crypto.cc ---------------------------------------------------------------------- diff --git a/src/kudu/security/crypto.cc b/src/kudu/security/crypto.cc index 1aab6b1..cf4199e 100644 --- a/src/kudu/security/crypto.cc +++ b/src/kudu/security/crypto.cc @@ -64,25 +64,25 @@ int DerWritePublicKey(BIO* bio, EVP_PKEY* key) { } // anonymous namespace template<> struct SslTypeTraits<BIGNUM> { - static constexpr auto free = &BN_free; + static constexpr auto kFreeFunc = &BN_free; }; struct RsaPrivateKeyTraits : public SslTypeTraits<EVP_PKEY> { - static constexpr auto read_pem = &PEM_read_bio_PrivateKey; - static constexpr auto read_der = &d2i_PrivateKey_bio; - static constexpr auto write_pem = &PemWritePrivateKey; - static constexpr auto write_der = &i2d_PrivateKey_bio; + static constexpr auto kReadPemFunc = &PEM_read_bio_PrivateKey; + static constexpr auto kReadDerFunc = &d2i_PrivateKey_bio; + static constexpr auto kWritePemFunc = &PemWritePrivateKey; + static constexpr auto kWriteDerFunc = &i2d_PrivateKey_bio; }; struct RsaPublicKeyTraits : public SslTypeTraits<EVP_PKEY> { - static constexpr auto read_pem = &PEM_read_bio_PUBKEY; - static constexpr auto read_der = &d2i_PUBKEY_bio; - static constexpr auto write_pem = &PemWritePublicKey; - static constexpr auto write_der = &DerWritePublicKey; + static constexpr auto kReadPemFunc = &PEM_read_bio_PUBKEY; + static constexpr auto kReadDerFunc = &d2i_PUBKEY_bio; + static constexpr auto kWritePemFunc = &PemWritePublicKey; + static constexpr auto kWriteDerFunc = &DerWritePublicKey; }; template<> struct SslTypeTraits<RSA> { - static constexpr auto free = &RSA_free; + static constexpr auto kFreeFunc = &RSA_free; }; template<> struct SslTypeTraits<EVP_MD_CTX> { - static constexpr auto free = &EVP_MD_CTX_destroy; + static constexpr auto kFreeFunc = &EVP_MD_CTX_destroy; }; namespace { http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/security/openssl_util.h ---------------------------------------------------------------------- diff --git a/src/kudu/security/openssl_util.h b/src/kudu/security/openssl_util.h index db85a85..82392c1 100644 --- a/src/kudu/security/openssl_util.h +++ b/src/kudu/security/openssl_util.h @@ -106,32 +106,32 @@ template<typename SSL_TYPE> struct SslTypeTraits {}; template<> struct SslTypeTraits<X509> { - static constexpr auto free = &X509_free; - static constexpr auto read_pem = &PEM_read_bio_X509; - static constexpr auto read_der = &d2i_X509_bio; - static constexpr auto write_pem = &PEM_write_bio_X509; - static constexpr auto write_der = &i2d_X509_bio; + static constexpr auto kFreeFunc = &X509_free; + static constexpr auto kReadPemFunc = &PEM_read_bio_X509; + static constexpr auto kReadDerFunc = &d2i_X509_bio; + static constexpr auto kWritePemFunc = &PEM_write_bio_X509; + static constexpr auto kWriteDerFunc = &i2d_X509_bio; }; template<> struct SslTypeTraits<X509_EXTENSION> { - static constexpr auto free = &X509_EXTENSION_free; + static constexpr auto kFreeFunc = &X509_EXTENSION_free; }; template<> struct SslTypeTraits<X509_REQ> { - static constexpr auto free = &X509_REQ_free; - static constexpr auto read_pem = &PEM_read_bio_X509_REQ; - static constexpr auto read_der = &d2i_X509_REQ_bio; - static constexpr auto write_pem = &PEM_write_bio_X509_REQ; - static constexpr auto write_der = &i2d_X509_REQ_bio; + static constexpr auto kFreeFunc = &X509_REQ_free; + static constexpr auto kReadPemFunc = &PEM_read_bio_X509_REQ; + static constexpr auto kReadDerFunc = &d2i_X509_REQ_bio; + static constexpr auto kWritePemFunc = &PEM_write_bio_X509_REQ; + static constexpr auto kWriteDerFunc = &i2d_X509_REQ_bio; }; template<> struct SslTypeTraits<EVP_PKEY> { - static constexpr auto free = &EVP_PKEY_free; + static constexpr auto kFreeFunc = &EVP_PKEY_free; }; template<> struct SslTypeTraits<SSL_CTX> { - static constexpr auto free = &SSL_CTX_free; + static constexpr auto kFreeFunc = &SSL_CTX_free; }; template<typename SSL_TYPE, typename Traits = SslTypeTraits<SSL_TYPE>> c_unique_ptr<SSL_TYPE> ssl_make_unique(SSL_TYPE* d) { - return {d, Traits::free}; + return {d, Traits::kFreeFunc}; } // Acceptable formats for keys, X509 certificates and X509 CSRs. http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/security/openssl_util_bio.h ---------------------------------------------------------------------- diff --git a/src/kudu/security/openssl_util_bio.h b/src/kudu/security/openssl_util_bio.h index 6ab6a55..d4dcc44 100644 --- a/src/kudu/security/openssl_util_bio.h +++ b/src/kudu/security/openssl_util_bio.h @@ -32,7 +32,7 @@ namespace kudu { namespace security { template<> struct SslTypeTraits<BIO> { - static constexpr auto free = &BIO_free; + static constexpr auto kFreeFunc = &BIO_free; }; template<typename TYPE, typename Traits = SslTypeTraits<TYPE>> @@ -41,11 +41,11 @@ Status ToBIO(BIO* bio, DataFormat format, TYPE* obj) { CHECK(obj); switch (format) { case DataFormat::DER: - OPENSSL_RET_NOT_OK(Traits::write_der(bio, obj), + OPENSSL_RET_NOT_OK(Traits::kWriteDerFunc(bio, obj), "error exporting data in DER format"); break; case DataFormat::PEM: - OPENSSL_RET_NOT_OK(Traits::write_pem(bio, obj), + OPENSSL_RET_NOT_OK(Traits::kWritePemFunc(bio, obj), "error exporting data in PEM format"); break; } @@ -58,10 +58,10 @@ Status FromBIO(BIO* bio, DataFormat format, c_unique_ptr<TYPE>* ret) { CHECK(bio); switch (format) { case DataFormat::DER: - *ret = ssl_make_unique(Traits::read_der(bio, nullptr)); + *ret = ssl_make_unique(Traits::kReadDerFunc(bio, nullptr)); break; case DataFormat::PEM: - *ret = ssl_make_unique(Traits::read_pem(bio, nullptr, nullptr, nullptr)); + *ret = ssl_make_unique(Traits::kReadPemFunc(bio, nullptr, nullptr, nullptr)); break; } if (PREDICT_FALSE(!*ret)) { http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/security/tls_context.cc ---------------------------------------------------------------------- diff --git a/src/kudu/security/tls_context.cc b/src/kudu/security/tls_context.cc index f28f31e..23b3d04 100644 --- a/src/kudu/security/tls_context.cc +++ b/src/kudu/security/tls_context.cc @@ -82,10 +82,10 @@ namespace security { using ca::CertRequestGenerator; template<> struct SslTypeTraits<SSL> { - static constexpr auto free = &SSL_free; + static constexpr auto kFreeFunc = &SSL_free; }; template<> struct SslTypeTraits<X509_STORE_CTX> { - static constexpr auto free = &X509_STORE_CTX_free; + static constexpr auto kFreeFunc = &X509_STORE_CTX_free; }; TlsContext::TlsContext() http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/server/pprof-path-handlers.cc ---------------------------------------------------------------------- diff --git a/src/kudu/server/pprof-path-handlers.cc b/src/kudu/server/pprof-path-handlers.cc index ade01da..eb4071f 100644 --- a/src/kudu/server/pprof-path-handlers.cc +++ b/src/kudu/server/pprof-path-handlers.cc @@ -61,7 +61,7 @@ bool Symbolize(void *pc, char *out, int out_size); namespace kudu { -const int PPROF_DEFAULT_SAMPLE_SECS = 30; // pprof default sample time in seconds. +const int kPprofDefaultSampleSecs = 30; // pprof default sample time in seconds. // pprof asks for the url /pprof/cmdline to figure out what application it's profiling. // The server should respond by sending the executable path. @@ -86,7 +86,7 @@ static void PprofHeapHandler(const Webserver::WebRequest& req, ostringstream* ou } auto it = req.parsed_args.find("seconds"); - int seconds = PPROF_DEFAULT_SAMPLE_SECS; + int seconds = kPprofDefaultSampleSecs; if (it != req.parsed_args.end()) { seconds = atoi(it->second.c_str()); } @@ -109,7 +109,7 @@ static void PprofCpuProfileHandler(const Webserver::WebRequest& req, ostringstre (*output) << "CPU profiling is not available without tcmalloc."; #else auto it = req.parsed_args.find("seconds"); - int seconds = PPROF_DEFAULT_SAMPLE_SECS; + int seconds = kPprofDefaultSampleSecs; if (it != req.parsed_args.end()) { seconds = atoi(it->second.c_str()); } @@ -144,7 +144,7 @@ static void PprofGrowthHandler(const Webserver::WebRequest& req, ostringstream* // Lock contention profiling static void PprofContentionHandler(const Webserver::WebRequest& req, ostringstream* output) { string secs_str = FindWithDefault(req.parsed_args, "seconds", ""); - int32_t seconds = ParseLeadingInt32Value(secs_str.c_str(), PPROF_DEFAULT_SAMPLE_SECS); + int32_t seconds = ParseLeadingInt32Value(secs_str.c_str(), kPprofDefaultSampleSecs); int64_t discarded_samples = 0; *output << "--- contention" << endl; http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/server/webserver.cc ---------------------------------------------------------------------- diff --git a/src/kudu/server/webserver.cc b/src/kudu/server/webserver.cc index 67fe64e..2c35402 100644 --- a/src/kudu/server/webserver.cc +++ b/src/kudu/server/webserver.cc @@ -459,7 +459,7 @@ void Webserver::RegisterPathHandler(const string& path, const string& alias, it->second->AddCallback(callback); } -const char* const PAGE_HEADER = "<!DOCTYPE html>" +const char* const kPageHeader = "<!DOCTYPE html>" " <html>" " <head><title>Kudu</title>" " <meta charset='utf-8'/>" @@ -470,7 +470,7 @@ const char* const PAGE_HEADER = "<!DOCTYPE html>" " </head>" " <body>"; -static const char* const NAVIGATION_BAR_PREFIX = +static const char* const kNavigationBarPrefix = "<div class='navbar navbar-inverse navbar-fixed-top'>" " <div class='navbar-inner'>" " <div class='container-fluid'>" @@ -480,7 +480,7 @@ static const char* const NAVIGATION_BAR_PREFIX = " <div class='nav-collapse collapse'>" " <ul class='nav'>"; -static const char* const NAVIGATION_BAR_SUFFIX = +static const char* const kNavigationBarSuffix = " </ul>" " </div>" " </div>" @@ -489,15 +489,15 @@ static const char* const NAVIGATION_BAR_SUFFIX = " <div class='container-fluid'>"; void Webserver::BootstrapPageHeader(ostringstream* output) { - (*output) << PAGE_HEADER; - (*output) << NAVIGATION_BAR_PREFIX; + (*output) << kPageHeader; + (*output) << kNavigationBarPrefix; for (const PathHandlerMap::value_type& handler : path_handlers_) { if (handler.second->is_on_nav_bar()) { (*output) << "<li><a href=\"" << handler.first << "\">" << handler.second->alias() << "</a></li>"; } } - (*output) << NAVIGATION_BAR_SUFFIX; + (*output) << kNavigationBarSuffix; if (!static_pages_available()) { (*output) << "<div style=\"color: red\"><strong>" http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/tablet/all_types-scan-correctness-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tablet/all_types-scan-correctness-test.cc b/src/kudu/tablet/all_types-scan-correctness-test.cc index 9f98730..73ebd45 100644 --- a/src/kudu/tablet/all_types-scan-correctness-test.cc +++ b/src/kudu/tablet/all_types-scan-correctness-test.cc @@ -66,7 +66,7 @@ struct RowOpsBase { template<typename KeyTypeWrapper> struct SliceTypeRowOps : public RowOpsBase { - SliceTypeRowOps() : RowOpsBase(KeyTypeWrapper::type, KeyTypeWrapper::encoding), + SliceTypeRowOps() : RowOpsBase(KeyTypeWrapper::kType, KeyTypeWrapper::kEncoding), strs_(kNumAllocatedElements), slices_(kNumAllocatedElements), cur(0) {} // Assumes the string representation of n is under strlen characters. @@ -88,10 +88,10 @@ struct SliceTypeRowOps : public RowOpsBase { Slice slice_a(string_a); Slice slice_b(string_b); Slice slice_c(string_c); - CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::type>>(kColA, slice_a)); - CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::type>>(kColB, slice_b)); + CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::kType>>(kColA, slice_a)); + CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::kType>>(kColB, slice_b)); if (altered) { - CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::type>>(kColC, slice_c)); + CHECK_OK(row->SetSliceCopy<TypeTraits<KeyTypeWrapper::kType>>(kColC, slice_c)); } } } @@ -122,10 +122,10 @@ struct SliceTypeRowOps : public RowOpsBase { template<typename KeyTypeWrapper> struct NumTypeRowOps : public RowOpsBase { - NumTypeRowOps() : RowOpsBase(KeyTypeWrapper::type, KeyTypeWrapper::encoding), + NumTypeRowOps() : RowOpsBase(KeyTypeWrapper::kType, KeyTypeWrapper::kEncoding), nums_(kNumAllocatedElements), cur(0) {} - typedef typename TypeTraits<KeyTypeWrapper::type>::cpp_type CppType; + typedef typename TypeTraits<KeyTypeWrapper::kType>::cpp_type CppType; void GenerateRow(int value, bool altered, KuduPartialRow* row) { if (value < 0) { @@ -135,10 +135,10 @@ struct NumTypeRowOps : public RowOpsBase { CHECK_OK(row->SetNull(kColC)); } } else { - row->Set<TypeTraits<KeyTypeWrapper::type>>(kColA, value); - row->Set<TypeTraits<KeyTypeWrapper::type>>(kColB, value); + row->Set<TypeTraits<KeyTypeWrapper::kType>>(kColA, value); + row->Set<TypeTraits<KeyTypeWrapper::kType>>(kColB, value); if (altered) { - row->Set<TypeTraits<KeyTypeWrapper::type>>(kColC, value); + row->Set<TypeTraits<KeyTypeWrapper::kType>>(kColC, value); } } } @@ -537,8 +537,8 @@ protected: template<DataType KeyType, EncodingType Encoding> struct KeyTypeWrapper { - static const DataType type = KeyType; - static const EncodingType encoding = Encoding; + static const DataType kType = KeyType; + static const EncodingType kEncoding = Encoding; }; typedef ::testing::Types<NumTypeRowOps<KeyTypeWrapper<INT8, BIT_SHUFFLE>>, http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/tablet/cbtree-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tablet/cbtree-test.cc b/src/kudu/tablet/cbtree-test.cc index 5f5fb9d..b60161a 100644 --- a/src/kudu/tablet/cbtree-test.cc +++ b/src/kudu/tablet/cbtree-test.cc @@ -85,10 +85,10 @@ TEST_F(TestCBTree, TestNodeSizes) { ThreadSafeArena arena(1024, 1024); LeafNode<BTreeTraits> lnode(false); - ASSERT_LE(sizeof(lnode), BTreeTraits::leaf_node_size); + ASSERT_LE(sizeof(lnode), BTreeTraits::kLeafNodeSize); InternalNode<BTreeTraits> inode(Slice("split"), &lnode, &lnode, &arena); - ASSERT_LE(sizeof(inode), BTreeTraits::internal_node_size); + ASSERT_LE(sizeof(inode), BTreeTraits::kInternalNodeSize); } @@ -157,15 +157,15 @@ TEST_F(TestCBTree, TestLeafNodeBigKVs) { // splitting, etc. struct SmallFanoutTraits : public BTreeTraits { - static const size_t internal_node_size = 84; - static const size_t leaf_node_size = 92; + static const size_t kInternalNodeSize = 84; + static const size_t kLeafNodeSize = 92; }; // Enables yield() calls at interesting points of the btree // implementation to ensure that we are still correct even // with adversarial scheduling. struct RacyTraits : public SmallFanoutTraits { - static const size_t debug_raciness = 100; + static const size_t kDebugRaciness = 100; }; void MakeKey(char *kbuf, size_t len, int i) { http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/tablet/concurrent_btree.h ---------------------------------------------------------------------- diff --git a/src/kudu/tablet/concurrent_btree.h b/src/kudu/tablet/concurrent_btree.h index b4c5012..ac7e536 100644 --- a/src/kudu/tablet/concurrent_btree.h +++ b/src/kudu/tablet/concurrent_btree.h @@ -77,15 +77,15 @@ namespace btree { struct BTreeTraits { enum TraitConstants { // Number of bytes used per internal node. - internal_node_size = 4 * CACHELINE_SIZE, + kInternalNodeSize = 4 * CACHELINE_SIZE, // Number of bytes used by a leaf node. - leaf_node_size = 4 * CACHELINE_SIZE, + kLeafNodeSize = 4 * CACHELINE_SIZE, // Tests can set this trait to a non-zero value, which inserts // some pause-loops in key parts of the code to try to simulate // races. - debug_raciness = 0 + kDebugRaciness = 0 }; typedef ThreadSafeArena ArenaType; }; @@ -106,8 +106,8 @@ inline void PrefetchMemory(const T *addr) { // will compile away in production code. template<class Traits> void DebugRacyPoint() { - if (Traits::debug_raciness > 0) { - boost::detail::yield(Traits::debug_raciness); + if (Traits::kDebugRaciness > 0) { + boost::detail::yield(Traits::kDebugRaciness); } } @@ -656,7 +656,7 @@ class PACKED InternalNode : public NodeBase<Traits> { enum SpaceConstants { constant_overhead = sizeof(NodeBase<Traits>) // base class + sizeof(uint32_t), // num_children_ - keyptr_space = Traits::internal_node_size - constant_overhead, + keyptr_space = Traits::kInternalNodeSize - constant_overhead, kFanout = keyptr_space / (sizeof(KeyInlineSlice) + sizeof(NodePtr<Traits>)) }; @@ -809,7 +809,7 @@ class LeafNode : public NodeBase<Traits> { constant_overhead = sizeof(NodeBase<Traits>) // base class + sizeof(LeafNode<Traits>*) // next_ + sizeof(uint8_t), // num_entries_ - kv_space = Traits::leaf_node_size - constant_overhead, + kv_space = Traits::kLeafNodeSize - constant_overhead, kMaxEntries = kv_space / (sizeof(KeyInlineSlice) + sizeof(ValueSlice)) }; http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/tserver/tablet_server.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tserver/tablet_server.cc b/src/kudu/tserver/tablet_server.cc index 20bde34..800ff10 100644 --- a/src/kudu/tserver/tablet_server.cc +++ b/src/kudu/tserver/tablet_server.cc @@ -49,7 +49,7 @@ TabletServer::TabletServer(const TabletServerOptions& opts) tablet_manager_(new TSTabletManager(fs_manager_.get(), this, metric_registry())), scanner_manager_(new ScannerManager(metric_entity())), path_handlers_(new TabletServerPathHandlers(this)), - maintenance_manager_(new MaintenanceManager(MaintenanceManager::DEFAULT_OPTIONS)) { + maintenance_manager_(new MaintenanceManager(MaintenanceManager::kDefaultOptions)) { } TabletServer::~TabletServer() { http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/debug/trace_event_impl.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/debug/trace_event_impl.cc b/src/kudu/util/debug/trace_event_impl.cc index 122cad1..f976c87 100644 --- a/src/kudu/util/debug/trace_event_impl.cc +++ b/src/kudu/util/debug/trace_event_impl.cc @@ -80,12 +80,12 @@ const char* g_category_groups[MAX_CATEGORY_GROUPS] = { // The enabled flag is char instead of bool so that the API can be used from C. unsigned char g_category_group_enabled[MAX_CATEGORY_GROUPS] = { 0 }; // Indexes here have to match the g_category_groups array indexes above. -const int g_category_already_shutdown = 1; -const int g_category_categories_exhausted = 2; -const int g_category_metadata = 3; -const int g_num_builtin_categories = 4; +const int kCategoryAlreadyShutdown = 1; +const int kCategoryCategoriesExhausted = 2; +const int kCategoryMetadata = 3; +const int kNumBuiltinCategories = 4; // Skip default categories. -AtomicWord g_category_index = g_num_builtin_categories; +AtomicWord g_category_index = kNumBuiltinCategories; // The name of the current thread. This is used to decide if the current // thread name has changed. We combine all the seen thread names into the @@ -366,7 +366,7 @@ void InitializeMetadataEvent(TraceEvent* trace_event, ::trace_event_internal::SetTraceValue(value, &arg_type, &arg_value); trace_event->Initialize(thread_id, MicrosecondsInt64(0), MicrosecondsInt64(0), TRACE_EVENT_PHASE_METADATA, - &g_category_group_enabled[g_category_metadata], + &g_category_group_enabled[kCategoryMetadata], metadata_name, ::trace_event_internal::kNoEventId, num_args, &arg_name, &arg_type, &arg_value, nullptr, TRACE_EVENT_FLAG_NONE); @@ -1147,8 +1147,8 @@ const unsigned char* TraceLog::GetCategoryGroupEnabled( const char* category_group) { TraceLog* tracelog = GetInstance(); if (!tracelog) { - DCHECK(!g_category_group_enabled[g_category_already_shutdown]); - return &g_category_group_enabled[g_category_already_shutdown]; + DCHECK(!g_category_group_enabled[kCategoryAlreadyShutdown]); + return &g_category_group_enabled[kCategoryAlreadyShutdown]; } return tracelog->GetCategoryGroupEnabledInternal(category_group); } @@ -1267,7 +1267,7 @@ const unsigned char* TraceLog::GetCategoryGroupEnabledInternal( base::subtle::Release_Store(&g_category_index, category_index + 1); } else { category_group_enabled = - &g_category_group_enabled[g_category_categories_exhausted]; + &g_category_group_enabled[kCategoryCategoriesExhausted]; } return category_group_enabled; } @@ -1276,7 +1276,7 @@ void TraceLog::GetKnownCategoryGroups( std::vector<std::string>* category_groups) { SpinLockHolder lock(&lock_); int category_index = base::subtle::NoBarrier_Load(&g_category_index); - for (int i = g_num_builtin_categories; i < category_index; i++) + for (int i = kNumBuiltinCategories; i < category_index; i++) category_groups->push_back(g_category_groups[i]); } http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/maintenance_manager.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/maintenance_manager.cc b/src/kudu/util/maintenance_manager.cc index 18ed8b8..b410646 100644 --- a/src/kudu/util/maintenance_manager.cc +++ b/src/kudu/util/maintenance_manager.cc @@ -111,7 +111,7 @@ void MaintenanceOp::Unregister() { manager_->UnregisterOp(this); } -const MaintenanceManager::Options MaintenanceManager::DEFAULT_OPTIONS = { +const MaintenanceManager::Options MaintenanceManager::kDefaultOptions = { .num_threads = 0, .polling_interval_ms = 0, .history_size = 0, http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/maintenance_manager.h ---------------------------------------------------------------------- diff --git a/src/kudu/util/maintenance_manager.h b/src/kudu/util/maintenance_manager.h index 6070e2d..1d2419a 100644 --- a/src/kudu/util/maintenance_manager.h +++ b/src/kudu/util/maintenance_manager.h @@ -282,7 +282,7 @@ class MaintenanceManager : public std::enable_shared_from_this<MaintenanceManage memory_pressure_func_ = std::move(f); } - static const Options DEFAULT_OPTIONS; + static const Options kDefaultOptions; private: FRIEND_TEST(MaintenanceManagerTest, TestLogRetentionPrioritization); http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/mem_tracker-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/mem_tracker-test.cc b/src/kudu/util/mem_tracker-test.cc index 7e78cbe..075931a 100644 --- a/src/kudu/util/mem_tracker-test.cc +++ b/src/kudu/util/mem_tracker-test.cc @@ -112,11 +112,11 @@ TEST(MemTrackerTest, TrackerHierarchy) { class GcFunctionHelper { public: - static const int NUM_RELEASE_BYTES = 1; + static const int kNumReleaseBytes = 1; explicit GcFunctionHelper(MemTracker* tracker) : tracker_(tracker) { } - void GcFunc() { tracker_->Release(NUM_RELEASE_BYTES); } + void GcFunc() { tracker_->Release(kNumReleaseBytes); } private: MemTracker* tracker_; http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/os-util.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/os-util.cc b/src/kudu/util/os-util.cc index 8874bd8..9ea7e08 100644 --- a/src/kudu/util/os-util.cc +++ b/src/kudu/util/os-util.cc @@ -51,18 +51,18 @@ namespace kudu { #define _SC_CLK_TCK 2 #endif -static const int64_t TICKS_PER_SEC = sysconf(_SC_CLK_TCK); +static const int64_t kTicksPerSec = sysconf(_SC_CLK_TCK); // Offsets into the ../stat file array of per-thread statistics. // // They are themselves offset by two because the pid and comm fields of the // file are parsed separately. -static const int64_t USER_TICKS = 13 - 2; -static const int64_t KERNEL_TICKS = 14 - 2; -static const int64_t IO_WAIT = 41 - 2; +static const int64_t kUserTicks = 13 - 2; +static const int64_t kKernelTicks = 14 - 2; +static const int64_t kIoWait = 41 - 2; // Largest offset we are interested in, to check we get a well formed stat file. -static const int64_t MAX_OFFSET = IO_WAIT; +static const int64_t kMaxOffset = kIoWait; Status ParseStat(const std::string& buffer, std::string* name, ThreadStats* stats) { DCHECK(stats != nullptr); @@ -80,19 +80,19 @@ Status ParseStat(const std::string& buffer, std::string* name, ThreadStats* stat string extracted_name = buffer.substr(open_paren + 1, close_paren - (open_paren + 1)); string rest = buffer.substr(close_paren + 2); vector<string> splits = Split(rest, " ", strings::SkipEmpty()); - if (splits.size() < MAX_OFFSET) { + if (splits.size() < kMaxOffset) { return Status::IOError("Unrecognised /proc format"); } int64 tmp; - if (safe_strto64(splits[USER_TICKS], &tmp)) { - stats->user_ns = tmp * (1e9 / TICKS_PER_SEC); + if (safe_strto64(splits[kUserTicks], &tmp)) { + stats->user_ns = tmp * (1e9 / kTicksPerSec); } - if (safe_strto64(splits[KERNEL_TICKS], &tmp)) { - stats->kernel_ns = tmp * (1e9 / TICKS_PER_SEC); + if (safe_strto64(splits[kKernelTicks], &tmp)) { + stats->kernel_ns = tmp * (1e9 / kTicksPerSec); } - if (safe_strto64(splits[IO_WAIT], &tmp)) { - stats->iowait_ns = tmp * (1e9 / TICKS_PER_SEC); + if (safe_strto64(splits[kIoWait], &tmp)) { + stats->iowait_ns = tmp * (1e9 / kTicksPerSec); } if (name != nullptr) { *name = extracted_name; @@ -103,7 +103,7 @@ Status ParseStat(const std::string& buffer, std::string* name, ThreadStats* stat Status GetThreadStats(int64_t tid, ThreadStats* stats) { DCHECK(stats != nullptr); - if (TICKS_PER_SEC <= 0) { + if (kTicksPerSec <= 0) { return Status::NotSupported("ThreadStats not supported"); } http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/process_memory.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/process_memory.cc b/src/kudu/util/process_memory.cc index 986e15a..59fab51 100644 --- a/src/kudu/util/process_memory.cc +++ b/src/kudu/util/process_memory.cc @@ -84,7 +84,7 @@ Atomic64 g_released_memory_since_gc; // A higher value will make us call into tcmalloc less often (and therefore more // efficient). A lower value will mean our memory overhead is lower. // TODO(todd): this is a stopgap. -const int64_t GC_RELEASE_SIZE = 128 * 1024L * 1024L; +const int64_t kGcReleaseSize = 128 * 1024L * 1024L; #endif // TCMALLOC_ENABLED @@ -264,7 +264,7 @@ void MaybeGCAfterRelease(int64_t released_bytes) { #ifdef TCMALLOC_ENABLED int64_t now_released = base::subtle::NoBarrier_AtomicIncrement( &g_released_memory_since_gc, -released_bytes); - if (PREDICT_FALSE(now_released > GC_RELEASE_SIZE)) { + if (PREDICT_FALSE(now_released > kGcReleaseSize)) { base::subtle::NoBarrier_Store(&g_released_memory_since_gc, 0); GcTcmalloc(); } http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/rle-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/rle-test.cc b/src/kudu/util/rle-test.cc index 185fed5..874bd71 100644 --- a/src/kudu/util/rle-test.cc +++ b/src/kudu/util/rle-test.cc @@ -35,7 +35,7 @@ using std::vector; namespace kudu { -const int MAX_WIDTH = 64; +const int kMaxWidth = 64; class TestRle : public KuduTest {}; @@ -123,7 +123,7 @@ void TestBitArrayValues(int bit_width, int num_vals) { } TEST(BitArray, TestValues) { - for (int width = 1; width <= MAX_WIDTH; ++width) { + for (int width = 1; width <= kMaxWidth; ++width) { TestBitArrayValues(width, 1); TestBitArrayValues(width, 2); // Don't write too many values @@ -225,7 +225,7 @@ TEST(Rle, SpecificSequences) { ValidateRle(values, width, expected_buffer, 4); } - for (int width = 9; width <= MAX_WIDTH; ++width) { + for (int width = 9; width <= kMaxWidth; ++width) { ValidateRle(values, width, nullptr, 2 * (1 + BitUtil::Ceil(width, 8))); } @@ -243,7 +243,7 @@ TEST(Rle, SpecificSequences) { // num_groups and expected_buffer only valid for bit width = 1 ValidateRle(values, 1, expected_buffer, 1 + num_groups); - for (int width = 2; width <= MAX_WIDTH; ++width) { + for (int width = 2; width <= kMaxWidth; ++width) { ValidateRle(values, width, nullptr, 1 + BitUtil::Ceil(width * 100, 8)); } } @@ -260,7 +260,7 @@ void TestRleValues(int bit_width, int num_vals, int value = -1) { } TEST(Rle, TestValues) { - for (int width = 1; width <= MAX_WIDTH; ++width) { + for (int width = 1; width <= kMaxWidth; ++width) { TestRleValues(width, 1); TestRleValues(width, 1024); TestRleValues(width, 1024, 0); @@ -320,7 +320,7 @@ TEST_F(BitRle, RandomBools) { } parity = !parity; } - ValidateRle(values, (iters % MAX_WIDTH) + 1, nullptr, -1); + ValidateRle(values, (iters % kMaxWidth) + 1, nullptr, -1); } } http://git-wip-us.apache.org/repos/asf/kudu/blob/e719b5ef/src/kudu/util/trace.h ---------------------------------------------------------------------- diff --git a/src/kudu/util/trace.h b/src/kudu/util/trace.h index 4d6df24..3c0f960 100644 --- a/src/kudu/util/trace.h +++ b/src/kudu/util/trace.h @@ -135,25 +135,25 @@ class Trace : public RefCountedThreadSafe<Trace> { void SubstituteAndTrace(const char* filepath, int line_number, StringPiece format, const strings::internal::SubstituteArg& arg0 = - strings::internal::SubstituteArg::NoArg, + strings::internal::SubstituteArg::kNoArg, const strings::internal::SubstituteArg& arg1 = - strings::internal::SubstituteArg::NoArg, + strings::internal::SubstituteArg::kNoArg, const strings::internal::SubstituteArg& arg2 = - strings::internal::SubstituteArg::NoArg, + strings::internal::SubstituteArg::kNoArg, const strings::internal::SubstituteArg& arg3 = - strings::internal::SubstituteArg::NoArg, + strings::internal::SubstituteArg::kNoArg, const strings::internal::SubstituteArg& arg4 = - strings::internal::SubstituteArg::NoArg, + strings::internal::SubstituteArg::kNoArg, const strings::internal::SubstituteArg& arg5 = - strings::internal::SubstituteArg::NoArg, + strings::internal::SubstituteArg::kNoArg, const strings::internal::SubstituteArg& arg6 = - strings::internal::SubstituteArg::NoArg, + strings::internal::SubstituteArg::kNoArg, const strings::internal::SubstituteArg& arg7 = - strings::internal::SubstituteArg::NoArg, + strings::internal::SubstituteArg::kNoArg, const strings::internal::SubstituteArg& arg8 = - strings::internal::SubstituteArg::NoArg, + strings::internal::SubstituteArg::kNoArg, const strings::internal::SubstituteArg& arg9 = - strings::internal::SubstituteArg::NoArg); + strings::internal::SubstituteArg::kNoArg); // Dump the trace buffer to the given output stream. //
