From fb799bc8f818574aacf380b2694aec011d2c18dd Mon Sep 17 00:00:00 2001 From: Leif Walsh Date: Mon, 10 Oct 2016 22:49:47 -0400 Subject: [PATCH] ARROW-112: Changed constexprs to kValue naming. Consistent with Google style. Author: Leif Walsh Closes #168 from leifwalsh/constant-name-fix-no-enum and squashes the following commits: 37a0b34 [Leif Walsh] ARROW-112: Changed constexprs to kValue naming. --- cpp/src/arrow/builder.h | 2 +- cpp/src/arrow/types/json.cc | 6 +++--- cpp/src/arrow/types/primitive-test.cc | 8 ++++---- cpp/src/arrow/types/primitive.cc | 2 +- cpp/src/arrow/util/bit-util.h | 10 +++++----- cpp/src/arrow/util/buffer.h | 2 -- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/cpp/src/arrow/builder.h b/cpp/src/arrow/builder.h index 5d9fb992ff0b5..646a6f24e9df8 100644 --- a/cpp/src/arrow/builder.h +++ b/cpp/src/arrow/builder.h @@ -33,7 +33,7 @@ class Array; class MemoryPool; class PoolBuffer; -static constexpr int32_t MIN_BUILDER_CAPACITY = 1 << 5; +static constexpr int32_t kMinBuilderCapacity = 1 << 5; // Base class for all data array builders. // This class provides a facilities for incrementally building the null bitmap diff --git a/cpp/src/arrow/types/json.cc b/cpp/src/arrow/types/json.cc index a4e0d085620a0..89240fc22bb2c 100644 --- a/cpp/src/arrow/types/json.cc +++ b/cpp/src/arrow/types/json.cc @@ -30,8 +30,8 @@ static const TypePtr String(new StringType()); static const TypePtr Double(new DoubleType()); static const TypePtr Bool(new BooleanType()); -static const std::vector json_types = {Null, Int32, String, Double, Bool}; -TypePtr JSONScalar::dense_type = TypePtr(new DenseUnionType(json_types)); -TypePtr JSONScalar::sparse_type = TypePtr(new SparseUnionType(json_types)); +static const std::vector kJsonTypes = {Null, Int32, String, Double, Bool}; +TypePtr JSONScalar::dense_type = TypePtr(new DenseUnionType(kJsonTypes)); +TypePtr JSONScalar::sparse_type = TypePtr(new SparseUnionType(kJsonTypes)); } // namespace arrow diff --git a/cpp/src/arrow/types/primitive-test.cc b/cpp/src/arrow/types/primitive-test.cc index 87eb0fe3a8bf7..5ac2867932df7 100644 --- a/cpp/src/arrow/types/primitive-test.cc +++ b/cpp/src/arrow/types/primitive-test.cc @@ -460,7 +460,7 @@ TYPED_TEST(TestPrimitiveBuilder, TestAdvance) { TYPED_TEST(TestPrimitiveBuilder, TestResize) { DECL_TYPE(); - int cap = MIN_BUILDER_CAPACITY * 2; + int cap = kMinBuilderCapacity * 2; ASSERT_OK(this->builder_->Reserve(cap)); ASSERT_EQ(cap, this->builder_->capacity()); @@ -472,13 +472,13 @@ TYPED_TEST(TestPrimitiveBuilder, TestResize) { TYPED_TEST(TestPrimitiveBuilder, TestReserve) { ASSERT_OK(this->builder_->Reserve(10)); ASSERT_EQ(0, this->builder_->length()); - ASSERT_EQ(MIN_BUILDER_CAPACITY, this->builder_->capacity()); + ASSERT_EQ(kMinBuilderCapacity, this->builder_->capacity()); ASSERT_OK(this->builder_->Reserve(90)); ASSERT_OK(this->builder_->Advance(100)); - ASSERT_OK(this->builder_->Reserve(MIN_BUILDER_CAPACITY)); + ASSERT_OK(this->builder_->Reserve(kMinBuilderCapacity)); - ASSERT_EQ(util::next_power2(MIN_BUILDER_CAPACITY + 100), this->builder_->capacity()); + ASSERT_EQ(util::next_power2(kMinBuilderCapacity + 100), this->builder_->capacity()); } } // namespace arrow diff --git a/cpp/src/arrow/types/primitive.cc b/cpp/src/arrow/types/primitive.cc index 375e94f2bc1c4..9ba2ebdcc2d5b 100644 --- a/cpp/src/arrow/types/primitive.cc +++ b/cpp/src/arrow/types/primitive.cc @@ -86,7 +86,7 @@ Status PrimitiveBuilder::Init(int32_t capacity) { template Status PrimitiveBuilder::Resize(int32_t capacity) { // XXX: Set floor size for now - if (capacity < MIN_BUILDER_CAPACITY) { capacity = MIN_BUILDER_CAPACITY; } + if (capacity < kMinBuilderCapacity) { capacity = kMinBuilderCapacity; } if (capacity_ == 0) { RETURN_NOT_OK(Init(capacity)); diff --git a/cpp/src/arrow/util/bit-util.h b/cpp/src/arrow/util/bit-util.h index 3087ce7784d11..c33ef272f05e2 100644 --- a/cpp/src/arrow/util/bit-util.h +++ b/cpp/src/arrow/util/bit-util.h @@ -44,22 +44,22 @@ static inline int64_t ceil_2bytes(int64_t size) { return (size + 15) & ~15; } -static constexpr uint8_t BITMASK[] = {1, 2, 4, 8, 16, 32, 64, 128}; +static constexpr uint8_t kBitmask[] = {1, 2, 4, 8, 16, 32, 64, 128}; static inline bool get_bit(const uint8_t* bits, int i) { - return static_cast(bits[i / 8] & BITMASK[i % 8]); + return static_cast(bits[i / 8] & kBitmask[i % 8]); } static inline bool bit_not_set(const uint8_t* bits, int i) { - return (bits[i / 8] & BITMASK[i % 8]) == 0; + return (bits[i / 8] & kBitmask[i % 8]) == 0; } static inline void clear_bit(uint8_t* bits, int i) { - bits[i / 8] &= ~BITMASK[i % 8]; + bits[i / 8] &= ~kBitmask[i % 8]; } static inline void set_bit(uint8_t* bits, int i) { - bits[i / 8] |= BITMASK[i % 8]; + bits[i / 8] |= kBitmask[i % 8]; } static inline int64_t next_power2(int64_t n) { diff --git a/cpp/src/arrow/util/buffer.h b/cpp/src/arrow/util/buffer.h index 01e4259c31fd2..bc0df86221c45 100644 --- a/cpp/src/arrow/util/buffer.h +++ b/cpp/src/arrow/util/buffer.h @@ -141,8 +141,6 @@ class ARROW_EXPORT PoolBuffer : public ResizableBuffer { MemoryPool* pool_; }; -static constexpr int64_t MIN_BUFFER_CAPACITY = 1024; - class BufferBuilder { public: explicit BufferBuilder(MemoryPool* pool)