bkietz commented on code in PR #43705:
URL: https://github.com/apache/arrow/pull/43705#discussion_r1722021848


##########
cpp/src/arrow/array/array_base.h:
##########
@@ -232,15 +233,32 @@ class ARROW_EXPORT Array {
   /// \return DeviceAllocationType
   DeviceAllocationType device_type() const { return data_->device_type(); }
 
+  /// \brief Return the statistics of this Array
+  ///
+  /// \return const std::shared_ptr<ArrayStatistics>&
+  const std::shared_ptr<ArrayStatistics>& statistics() const { return 
statistics_; }
+
  protected:
   Array() = default;
   ARROW_DEFAULT_MOVE_AND_ASSIGN(Array);
 
   std::shared_ptr<ArrayData> data_;
   const uint8_t* null_bitmap_data_ = NULLPTR;
 
-  /// Protected method for constructors
-  void SetData(const std::shared_ptr<ArrayData>& data) {
+  /// Protected method for constructors. This must be called from each
+  /// array class to call its SetData(). You can't use call this in a
+  /// parent array class.
+  void Init(const std::shared_ptr<ArrayData>& data,
+            const std::shared_ptr<ArrayStatistics>& statistics) {
+    SetData(data);
+    if (statistics) {
+      SetStatistics(statistics);
+    }
+  }
+
+  /// Protected method for constructors. Don't call this method
+  /// directly. This should be called from Init().
+  virtual void SetData(const std::shared_ptr<ArrayData>& data) {

Review Comment:
   This probably shouldn't be virtual since it's called from constructors, 
[which adds 
nuances.](https://en.cppreference.com/w/cpp/language/virtual#During_construction_and_destruction)
 Specifically, if `BaseArray::BaseArray()` calls `Array::Init()` then that will 
not call `DerivedArray::SetData()`.
   
   Is there a reason to leave this virtual?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to