Skip to content

Commit

Permalink
Remove TypedArrayStatistics
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jul 12, 2024
1 parent 8b02c51 commit cb2cb97
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 49 deletions.
10 changes: 0 additions & 10 deletions cpp/src/arrow/array/array_primitive.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<BooleanArrayStatistics> statistics() const {
return std::static_pointer_cast<BooleanArrayStatistics>(statistics_);
}

protected:
using PrimitiveArray::PrimitiveArray;

Expand Down Expand Up @@ -130,11 +125,6 @@ class NumericArray : public PrimitiveArray {

IteratorType end() const { return IteratorType(*this, length()); }

/// \brief Return the typed statistics.
std::shared_ptr<TypedArrayStatistics<TYPE>> statistics() const {
return std::static_pointer_cast<TypedArrayStatistics<TYPE>>(Array::statistics());
}

protected:
using PrimitiveArray::PrimitiveArray;
};
Expand Down
25 changes: 0 additions & 25 deletions cpp/src/arrow/array/statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,4 @@ struct ARROW_EXPORT ArrayStatistics {
}
};

/// \brief A typed implementation of ArrayStatistics
template <typename TypeClass>
class TypedArrayStatistics : public ArrayStatistics {
public:
using ElementType = typename TypeClass::c_type;

/// \brief The current minimum value, may not be set
std::optional<ElementType> min() const {
if (min_buffer && std::holds_alternative<ElementType>(*min_buffer)) {
return std::get<ElementType>(*min_buffer);
} else {
return std::nullopt;
}
}

/// \brief The current maximum value, may not be set
std::optional<ElementType> max() const {
if (max_buffer && std::holds_alternative<ElementType>(*max_buffer)) {
return std::get<ElementType>(*max_buffer);
} else {
return std::nullopt;
}
}
};

} // namespace arrow
5 changes: 0 additions & 5 deletions cpp/src/arrow/type_fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ using ChunkedArrayVector = std::vector<std::shared_ptr<ChunkedArray>>;
using RecordBatchVector = std::vector<std::shared_ptr<RecordBatch>>;
using RecordBatchIterator = Iterator<std::shared_ptr<RecordBatch>>;

template <typename TypeClass>
class TypedArrayStatistics;

class DictionaryType;
class DictionaryArray;
struct DictionaryScalar;
Expand All @@ -105,7 +102,6 @@ class FixedWidthType;

class BooleanType;
class BooleanArray;
using BooleanArrayStatistics = TypedArrayStatistics<BooleanType>;
class BooleanBuilder;
struct BooleanScalar;

Expand Down Expand Up @@ -222,7 +218,6 @@ class NumericTensor;
#define _NUMERIC_TYPE_DECL(KLASS) \
class KLASS##Type; \
using KLASS##Array = NumericArray<KLASS##Type>; \
using KLASS##ArrayStatistics = TypedArrayStatistics<KLASS##Type>; \
using KLASS##Builder = NumericBuilder<KLASS##Type>; \
struct KLASS##Scalar; \
using KLASS##Tensor = NumericTensor<KLASS##Type>;
Expand Down
20 changes: 12 additions & 8 deletions cpp/src/parquet/arrow/arrow_statistics_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>(*statistics->min_buffer));
ASSERT_EQ(true, std::get<bool>(*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<bool>(*statistics->max_buffer));
ASSERT_EQ(true, std::get<bool>(*statistics->max_buffer));
ASSERT_EQ(true, statistics->is_min_exact.has_value());
ASSERT_EQ(true, statistics->is_min_exact.value());
}
Expand All @@ -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<int8_t>(*statistics->min_buffer));
ASSERT_EQ(-1, std::get<int8_t>(*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<int8_t>(*statistics->max_buffer));
ASSERT_EQ(1, std::get<int8_t>(*statistics->max_buffer));
ASSERT_EQ(true, statistics->is_min_exact.has_value());
ASSERT_EQ(true, statistics->is_min_exact.value());
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/arrow/reader_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit cb2cb97

Please sign in to comment.