mapleFU commented on code in PR #44190: URL: https://github.com/apache/arrow/pull/44190#discussion_r1818534498
########## cpp/src/arrow/array/array_primitive.h: ########## @@ -90,26 +90,25 @@ class NumericArray : public PrimitiveArray { using value_type = typename TypeClass::c_type; using IteratorType = stl::ArrayIterator<NumericArray<TYPE>>; - explicit NumericArray(const std::shared_ptr<ArrayData>& data) : PrimitiveArray(data) {} + explicit NumericArray(const std::shared_ptr<ArrayData>& data) { SetData(data); } // Only enable this constructor without a type argument for types without additional // metadata template <typename T1 = TYPE> NumericArray(enable_if_parameter_free<T1, int64_t> length, const std::shared_ptr<Buffer>& data, const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, - int64_t null_count = kUnknownNullCount, int64_t offset = 0) - : PrimitiveArray(TypeTraits<T1>::type_singleton(), length, data, null_bitmap, - null_count, offset) {} - - const value_type* raw_values() const { - return reinterpret_cast<const value_type*>(raw_values_) + data_->offset; + int64_t null_count = kUnknownNullCount, int64_t offset = 0) { + SetData(ArrayData::Make(TypeTraits<T1>::type_singleton(), length, {null_bitmap, data}, Review Comment: Would be fixed with ``` diff --git a/cpp/src/arrow/array/array_primitive.h b/cpp/src/arrow/array/array_primitive.h index 3e2893b7dd..410e8516da 100644 --- a/cpp/src/arrow/array/array_primitive.h +++ b/cpp/src/arrow/array/array_primitive.h @@ -103,6 +103,15 @@ class NumericArray : public PrimitiveArray { null_count, offset)); } + NumericArray(const std::shared_ptr<DataType>& type, int64_t length, + const std::shared_ptr<Buffer>& data, + const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, + int64_t null_count = kUnknownNullCount, int64_t offset = 0): PrimitiveArray(type, length, data, null_bitmap, null_count, offset) { + values_ = raw_values_ + ? (reinterpret_cast<const value_type*>(raw_values_) + data_->offset) + : NULLPTR; + } + const value_type* raw_values() const { return values_; } value_type Value(int64_t i) const { return values_[i]; } ``` For `NumericArray` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org