This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new b80a51a65c GH-43594: [C++] Remove std::optional from 
arrow::ArrayStatistics::is_{min,max}_exact (#43595)
b80a51a65c is described below

commit b80a51a65c8031bbd2d1d2e5645c541bd7076b5b
Author: Sutou Kouhei <[email protected]>
AuthorDate: Fri Aug 16 14:23:05 2024 +0900

    GH-43594: [C++] Remove std::optional from 
arrow::ArrayStatistics::is_{min,max}_exact (#43595)
    
    ### Rationale for this change
    
    We don't need "unknown" state. If they aren't set, we can process they are 
not exact.
    
    ### What changes are included in this PR?
    
    Remove `std::optional` from `arrow::ArrayStatistics::is_{min,max}_exact`.
    
    ### Are these changes tested?
    
    Yes.
    
    ### Are there any user-facing changes?
    
    Yes.
    * GitHub Issue: #43594
    
    Authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 cpp/src/arrow/array/statistics.h       |  8 ++++----
 cpp/src/arrow/array/statistics_test.cc | 14 ++++++--------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/cpp/src/arrow/array/statistics.h b/cpp/src/arrow/array/statistics.h
index 816d68e777..523f877bbe 100644
--- a/cpp/src/arrow/array/statistics.h
+++ b/cpp/src/arrow/array/statistics.h
@@ -43,14 +43,14 @@ struct ARROW_EXPORT ArrayStatistics {
   /// \brief The minimum value, may not be set
   std::optional<ValueType> min = std::nullopt;
 
-  /// \brief Whether the minimum value is exact or not, may not be set
-  std::optional<bool> is_min_exact = std::nullopt;
+  /// \brief Whether the minimum value is exact or not
+  bool is_min_exact = false;
 
   /// \brief The maximum value, may not be set
   std::optional<ValueType> max = std::nullopt;
 
-  /// \brief Whether the maximum value is exact or not, may not be set
-  std::optional<bool> is_max_exact = std::nullopt;
+  /// \brief Whether the maximum value is exact or not
+  bool is_max_exact = false;
 
   /// \brief Check two statistics for equality
   bool Equals(const ArrayStatistics& other) const {
diff --git a/cpp/src/arrow/array/statistics_test.cc 
b/cpp/src/arrow/array/statistics_test.cc
index f4f4f50015..cf15a5d382 100644
--- a/cpp/src/arrow/array/statistics_test.cc
+++ b/cpp/src/arrow/array/statistics_test.cc
@@ -40,27 +40,25 @@ TEST(ArrayStatisticsTest, TestDistinctCount) {
 TEST(ArrayStatisticsTest, TestMin) {
   ArrayStatistics statistics;
   ASSERT_FALSE(statistics.min.has_value());
-  ASSERT_FALSE(statistics.is_min_exact.has_value());
+  ASSERT_FALSE(statistics.is_min_exact);
   statistics.min = static_cast<uint64_t>(29);
   statistics.is_min_exact = true;
   ASSERT_TRUE(statistics.min.has_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());
+  ASSERT_TRUE(statistics.is_min_exact);
 }
 
 TEST(ArrayStatisticsTest, TestMax) {
   ArrayStatistics statistics;
   ASSERT_FALSE(statistics.max.has_value());
-  ASSERT_FALSE(statistics.is_max_exact.has_value());
+  ASSERT_FALSE(statistics.is_max_exact);
   statistics.max = std::string("hello");
   statistics.is_max_exact = false;
   ASSERT_TRUE(statistics.max.has_value());
   ASSERT_TRUE(std::holds_alternative<std::string>(statistics.max.value()));
   ASSERT_EQ("hello", std::get<std::string>(statistics.max.value()));
-  ASSERT_TRUE(statistics.is_max_exact.has_value());
-  ASSERT_FALSE(statistics.is_max_exact.value());
+  ASSERT_FALSE(statistics.is_max_exact);
 }
 
 TEST(ArrayStatisticsTest, TestEquality) {
@@ -84,9 +82,9 @@ TEST(ArrayStatisticsTest, TestEquality) {
   statistics2.min = std::string("world");
   ASSERT_EQ(statistics1, statistics2);
 
-  statistics1.is_min_exact = false;
+  statistics1.is_min_exact = true;
   ASSERT_NE(statistics1, statistics2);
-  statistics2.is_min_exact = false;
+  statistics2.is_min_exact = true;
   ASSERT_EQ(statistics1, statistics2);
 
   statistics1.max = static_cast<int64_t>(-29);

Reply via email to