Skip to content

Commit

Permalink
apacheGH-43578: [C++] Simplify arrow::ArrayStatistics::ValueType
Browse files Browse the repository at this point in the history
We can cover integer values by `int64_t` and `uint64_t` and float
values by `double`.

We can remove `std::string_view` because we don't support out of
`ArrayStatistics` string/binary data.
  • Loading branch information
kou committed Aug 6, 2024
1 parent 51d50d7 commit 3a86479
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 1 addition & 3 deletions cpp/src/arrow/array/statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ namespace arrow {
/// as Apache Parquet may have statistics. Statistics associated with
/// data source can be read unified API via this class.
struct ARROW_EXPORT ArrayStatistics {
using ValueType =
std::variant<bool, int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t,
uint64_t, util::Float16, float, double, std::string, std::string_view>;
using ValueType = std::variant<bool, int64_t, uint64_t, double, std::string>;

ArrayStatistics() = default;
~ArrayStatistics() = default;
Expand Down
14 changes: 7 additions & 7 deletions cpp/src/arrow/array/statistics_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ TEST(ArrayStatisticsTest, TestMin) {
ArrayStatistics statistics;
ASSERT_FALSE(statistics.min.has_value());
ASSERT_FALSE(statistics.is_min_exact.has_value());
statistics.min = static_cast<int32_t>(29);
statistics.min = static_cast<uint64_t>(29);
statistics.is_min_exact = true;
ASSERT_TRUE(statistics.min.has_value());
ASSERT_TRUE(std::holds_alternative<int32_t>(statistics.min.value()));
ASSERT_EQ(29, std::get<int32_t>(statistics.min.value()));
ASSERT_TRUE(std::holds_alternative<uint64_t>(statistics.min.value()));
ASSERT_EQ(29, std::get<uint64_t>(statistics.min.value()));
ASSERT_TRUE(statistics.is_min_exact.has_value());
ASSERT_TRUE(statistics.is_min_exact.value());
}
Expand Down Expand Up @@ -79,19 +79,19 @@ TEST(ArrayStatisticsTest, TestEquality) {
statistics2.distinct_count = 2929;
ASSERT_EQ(statistics1, statistics2);

statistics1.min = std::string_view("world");
statistics1.min = std::string("world");
ASSERT_NE(statistics1, statistics2);
statistics2.min = std::string_view("world");
statistics2.min = std::string("world");
ASSERT_EQ(statistics1, statistics2);

statistics1.is_min_exact = false;
ASSERT_NE(statistics1, statistics2);
statistics2.is_min_exact = false;
ASSERT_EQ(statistics1, statistics2);

statistics1.max = arrow::util::Float16(-29);
statistics1.max = -29;
ASSERT_NE(statistics1, statistics2);
statistics2.max = arrow::util::Float16(-29);
statistics2.max = -29;
ASSERT_EQ(statistics1, statistics2);

statistics1.is_max_exact = true;
Expand Down

0 comments on commit 3a86479

Please sign in to comment.