felipecrv commented on code in PR #42133:
URL: https://github.com/apache/arrow/pull/42133#discussion_r1674628047


##########
cpp/src/arrow/array/array_base.h:
##########
@@ -232,6 +232,14 @@ class ARROW_EXPORT Array {
   /// \return DeviceAllocationType
   DeviceAllocationType device_type() const { return data_->device_type(); }
 
+  /// \brief Return the statistics of this Array
+  ///
+  /// This just delegates to calling statistics on the underlying ArrayData
+  /// object which backs this Array.
+  ///
+  /// \return const ArrayStatistics&
+  const ArrayStatistics& statistics() const { return data_->statistics; }

Review Comment:
   There shouldn't be a public statistics setter in `Array` — an immutable 
class: `SetStatistics` should be `protected` just like `SetData`.
   
   Leave the existing constructor as is, extend the `protected` constructor 
that takes `ArrayData`:
   
   ```diff
     protected:
      PrimitiveArray() : raw_values_(NULLPTR) {}
   
      void SetData(const std::shared_ptr<ArrayData>& data) {
        this->Array::SetData(data);
        raw_values_ = data->GetValuesSafe<uint8_t>(1, /*offset=*/0);
      }
   
   -  explicit PrimitiveArray(const std::shared_ptr<ArrayData>& data) { 
SetData(data); }
   +  PrimitiveArray(const std::shared_ptr<ArrayData>& data,
   +                 std::shared_ptr<ArrayStats> stats) {
   +    SetData(data);
   +    if (stats) {
   +      SetStats(std::move(stats));
   +    }
   + }
   
      const uint8_t* raw_values_;
   ```
   
   Then you change `BooleanArray` constructor that takes `ArrayData` to also 
take statistics:
   
   ```diff
   -  explicit BooleanArray(const std::shared_ptr<ArrayData>& data);
   +  explicit BooleanArray(const std::shared_ptr<ArrayData>& data,
   +                        std::shared_ptr<ArrayStats> stats = nullptr);
   ```
   
   



-- 
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

Reply via email to