From cb2cb97b7fa6eb24725fd60a4d04f84c778b07c9 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Fri, 12 Jul 2024 15:03:29 +0900 Subject: [PATCH] Remove TypedArrayStatistics --- cpp/src/arrow/array/array_primitive.h | 10 -------- cpp/src/arrow/array/statistics.h | 25 ------------------- cpp/src/arrow/type_fwd.h | 5 ---- .../parquet/arrow/arrow_statistics_test.cc | 20 +++++++++------ cpp/src/parquet/arrow/reader_internal.cc | 2 +- 5 files changed, 13 insertions(+), 49 deletions(-) diff --git a/cpp/src/arrow/array/array_primitive.h b/cpp/src/arrow/array/array_primitive.h index 19251a88742ea..ab82fde8777ea 100644 --- a/cpp/src/arrow/array/array_primitive.h +++ b/cpp/src/arrow/array/array_primitive.h @@ -70,11 +70,6 @@ class ARROW_EXPORT BooleanArray : public PrimitiveArray { IteratorType end() const { return IteratorType(*this, length()); } - /// \brief Return the statistics for boolean. - std::shared_ptr statistics() const { - return std::static_pointer_cast(statistics_); - } - protected: using PrimitiveArray::PrimitiveArray; @@ -130,11 +125,6 @@ class NumericArray : public PrimitiveArray { IteratorType end() const { return IteratorType(*this, length()); } - /// \brief Return the typed statistics. - std::shared_ptr> statistics() const { - return std::static_pointer_cast>(Array::statistics()); - } - protected: using PrimitiveArray::PrimitiveArray; }; diff --git a/cpp/src/arrow/array/statistics.h b/cpp/src/arrow/array/statistics.h index 43dfd656b31d6..80ac0e157e2d5 100644 --- a/cpp/src/arrow/array/statistics.h +++ b/cpp/src/arrow/array/statistics.h @@ -63,29 +63,4 @@ struct ARROW_EXPORT ArrayStatistics { } }; -/// \brief A typed implementation of ArrayStatistics -template -class TypedArrayStatistics : public ArrayStatistics { - public: - using ElementType = typename TypeClass::c_type; - - /// \brief The current minimum value, may not be set - std::optional min() const { - if (min_buffer && std::holds_alternative(*min_buffer)) { - return std::get(*min_buffer); - } else { - return std::nullopt; - } - } - - /// \brief The current maximum value, may not be set - std::optional max() const { - if (max_buffer && std::holds_alternative(*max_buffer)) { - return std::get(*max_buffer); - } else { - return std::nullopt; - } - } -}; - } // namespace arrow diff --git a/cpp/src/arrow/type_fwd.h b/cpp/src/arrow/type_fwd.h index 54d3e09f01d26..ecaceaf46901e 100644 --- a/cpp/src/arrow/type_fwd.h +++ b/cpp/src/arrow/type_fwd.h @@ -89,9 +89,6 @@ using ChunkedArrayVector = std::vector>; using RecordBatchVector = std::vector>; using RecordBatchIterator = Iterator>; -template -class TypedArrayStatistics; - class DictionaryType; class DictionaryArray; struct DictionaryScalar; @@ -105,7 +102,6 @@ class FixedWidthType; class BooleanType; class BooleanArray; -using BooleanArrayStatistics = TypedArrayStatistics; class BooleanBuilder; struct BooleanScalar; @@ -222,7 +218,6 @@ class NumericTensor; #define _NUMERIC_TYPE_DECL(KLASS) \ class KLASS##Type; \ using KLASS##Array = NumericArray; \ - using KLASS##ArrayStatistics = TypedArrayStatistics; \ using KLASS##Builder = NumericBuilder; \ struct KLASS##Scalar; \ using KLASS##Tensor = NumericTensor; diff --git a/cpp/src/parquet/arrow/arrow_statistics_test.cc b/cpp/src/parquet/arrow/arrow_statistics_test.cc index 561385c077047..488fdd9543d5e 100644 --- a/cpp/src/parquet/arrow/arrow_statistics_test.cc +++ b/cpp/src/parquet/arrow/arrow_statistics_test.cc @@ -190,12 +190,14 @@ TEST(TestStatisticsRead, Boolean) { ASSERT_EQ(true, statistics->null_count.has_value()); ASSERT_EQ(1, statistics->null_count.value()); ASSERT_EQ(false, statistics->distinct_count.has_value()); - ASSERT_EQ(true, statistics->min().has_value()); - ASSERT_EQ(true, statistics->min().value()); + ASSERT_EQ(true, statistics->min_buffer.has_value()); + ASSERT_EQ(true, std::holds_alternative(*statistics->min_buffer)); + ASSERT_EQ(true, std::get(*statistics->min_buffer)); ASSERT_EQ(true, statistics->is_min_exact.has_value()); ASSERT_EQ(true, statistics->is_min_exact.value()); - ASSERT_EQ(true, statistics->max().has_value()); - ASSERT_EQ(true, statistics->max().value()); + ASSERT_EQ(true, statistics->max_buffer.has_value()); + ASSERT_EQ(true, std::holds_alternative(*statistics->max_buffer)); + ASSERT_EQ(true, std::get(*statistics->max_buffer)); ASSERT_EQ(true, statistics->is_min_exact.has_value()); ASSERT_EQ(true, statistics->is_min_exact.value()); } @@ -208,12 +210,14 @@ TEST(TestStatisticsRead, Int8) { ASSERT_EQ(true, statistics->null_count.has_value()); ASSERT_EQ(1, statistics->null_count.value()); ASSERT_EQ(false, statistics->distinct_count.has_value()); - ASSERT_EQ(true, statistics->min().has_value()); - ASSERT_EQ(-1, statistics->min().value()); + ASSERT_EQ(true, statistics->min_buffer.has_value()); + ASSERT_EQ(true, std::holds_alternative(*statistics->min_buffer)); + ASSERT_EQ(-1, std::get(*statistics->min_buffer)); ASSERT_EQ(true, statistics->is_min_exact.has_value()); ASSERT_EQ(true, statistics->is_min_exact.value()); - ASSERT_EQ(true, statistics->max().has_value()); - ASSERT_EQ(1, statistics->max().value()); + ASSERT_EQ(true, statistics->max_buffer.has_value()); + ASSERT_EQ(true, std::holds_alternative(*statistics->max_buffer)); + ASSERT_EQ(1, std::get(*statistics->max_buffer)); ASSERT_EQ(true, statistics->is_min_exact.has_value()); ASSERT_EQ(true, statistics->is_min_exact.value()); } diff --git a/cpp/src/parquet/arrow/reader_internal.cc b/cpp/src/parquet/arrow/reader_internal.cc index 75d0557b386f9..14cd42e638f91 100644 --- a/cpp/src/parquet/arrow/reader_internal.cc +++ b/cpp/src/parquet/arrow/reader_internal.cc @@ -404,7 +404,7 @@ Status TransferBool(RecordReader* reader, } auto array_data = ::arrow::ArrayData::Make(::arrow::boolean(), length, std::move(buffers), null_count); - auto array_statistics = std::make_shared<::arrow::BooleanArrayStatistics>(); + auto array_statistics = std::make_shared<::arrow::ArrayStatistics>(); array_statistics->null_count = null_count; auto statistics = metadata->statistics().get(); if (statistics) {