diff --git a/cpp/src/arrow/types/primitive.cc b/cpp/src/arrow/types/primitive.cc index 8e6c0f809ca44..08fc8478e6de5 100644 --- a/cpp/src/arrow/types/primitive.cc +++ b/cpp/src/arrow/types/primitive.cc @@ -162,6 +162,11 @@ BooleanArray::BooleanArray(int32_t length, const std::shared_ptr& data, : PrimitiveArray( std::make_shared(), length, data, null_count, null_bitmap) {} +BooleanArray::BooleanArray(const TypePtr& type, int32_t length, + const std::shared_ptr& data, int32_t null_count, + const std::shared_ptr& null_bitmap) + : PrimitiveArray(type, length, data, null_count, null_bitmap) {} + bool BooleanArray::EqualsExact(const BooleanArray& other) const { if (this == &other) return true; if (null_count_ != other.null_count_) { return false; } diff --git a/cpp/src/arrow/types/primitive.h b/cpp/src/arrow/types/primitive.h index 9597fc8363138..f1ec417d51014 100644 --- a/cpp/src/arrow/types/primitive.h +++ b/cpp/src/arrow/types/primitive.h @@ -34,11 +34,10 @@ namespace arrow { class MemoryPool; -// Base class for fixed-size logical types +// Base class for fixed-size logical types. See MakePrimitiveArray +// (types/construct.h) for constructing a specific subclass. class PrimitiveArray : public Array { public: - PrimitiveArray(const TypePtr& type, int32_t length, const std::shared_ptr& data, - int32_t null_count = 0, const std::shared_ptr& null_bitmap = nullptr); virtual ~PrimitiveArray() {} const std::shared_ptr& data() const { return data_; } @@ -47,6 +46,8 @@ class PrimitiveArray : public Array { bool Equals(const std::shared_ptr& arr) const override; protected: + PrimitiveArray(const TypePtr& type, int32_t length, const std::shared_ptr& data, + int32_t null_count = 0, const std::shared_ptr& null_bitmap = nullptr); std::shared_ptr data_; const uint8_t* raw_data_; }; @@ -55,12 +56,14 @@ class PrimitiveArray : public Array { class NAME : public PrimitiveArray { \ public: \ using value_type = T; \ - using PrimitiveArray::PrimitiveArray; \ \ NAME(int32_t length, const std::shared_ptr& data, int32_t null_count = 0, \ const std::shared_ptr& null_bitmap = nullptr) \ : PrimitiveArray( \ std::make_shared(), length, data, null_count, null_bitmap) {} \ + NAME(const TypePtr& type, int32_t length, const std::shared_ptr& data, \ + int32_t null_count = 0, const std::shared_ptr& null_bitmap = nullptr) \ + : PrimitiveArray(type, length, data, null_count, null_bitmap) {} \ \ bool EqualsExact(const NAME& other) const { \ return PrimitiveArray::EqualsExact(*static_cast(&other)); \ @@ -261,10 +264,10 @@ typedef NumericBuilder DoubleBuilder; class BooleanArray : public PrimitiveArray { public: - using PrimitiveArray::PrimitiveArray; - BooleanArray(int32_t length, const std::shared_ptr& data, int32_t null_count = 0, const std::shared_ptr& null_bitmap = nullptr); + BooleanArray(const TypePtr& type, int32_t length, const std::shared_ptr& data, + int32_t null_count = 0, const std::shared_ptr& null_bitmap = nullptr); bool EqualsExact(const BooleanArray& other) const; bool Equals(const ArrayPtr& arr) const override;