HuaHuaY commented on code in PR #50807:
URL: https://github.com/apache/arrow/pull/50807#discussion_r4053826029


##########
cpp/src/parquet/statistics_test.cc:
##########
@@ -1670,10 +1706,85 @@ TYPED_TEST(TestFloatStatistics, NegativeZeros) { 
this->TestNegativeZeroes(); }
 TYPED_TEST(TestFloatStatistics, NaNs) { this->TestNaNs(); }
 TYPED_TEST(TestFloatStatistics, Infinities) { this->TestInfinities(); }
 
+template <typename DType, typename UInt>
+void TestNativeTotalOrder(UInt negative_nan_bits, UInt positive_nan_bits) {
+  using T = typename DType::c_type;
+  auto node = schema::PrimitiveNode::Make("f", Repetition::REQUIRED, 
DType::type_num);
+  std::static_pointer_cast<schema::PrimitiveNode>(node)->SetColumnOrder(
+      ColumnOrder::ieee_754_total_order_);
+  ColumnDescriptor descr(node, 0, 0);
+
+  const T negative_nan = SafeCopy<T>(negative_nan_bits);
+  const T positive_nan = SafeCopy<T>(positive_nan_bits);
+  const T positive_zero = T{0};
+  std::array<T, 3> mixed{negative_nan, positive_zero, positive_nan};
+  auto stats = MakeStatistics<DType>(&descr);
+  stats->Update(mixed.data(), mixed.size(), 0);
+  ASSERT_EQ(std::make_optional<int64_t>(2), stats->nan_count());
+  ASSERT_TRUE(stats->HasMinMax());
+  ASSERT_FALSE(std::signbit(stats->min()));
+  ASSERT_FALSE(std::signbit(stats->max()));
+
+  std::array<T, 2> all_nan{positive_nan, negative_nan};
+  stats->Reset();
+  stats->Update(all_nan.data(), all_nan.size(), 0);
+  ASSERT_EQ(std::make_optional<int64_t>(2), stats->nan_count());
+  ASSERT_EQ(negative_nan_bits, SafeCopy<UInt>(stats->min()));
+  ASSERT_EQ(positive_nan_bits, SafeCopy<UInt>(stats->max()));
+
+  auto same = MakeStatistics<DType>(&descr);
+  same->Update(all_nan.data(), all_nan.size(), 0);
+  ASSERT_TRUE(stats->Equals(*same));
+
+  auto numeric = MakeStatistics<DType>(&descr);
+  std::array<T, 1> values{T{1}};
+  numeric->Update(values.data(), values.size(), 0);
+  stats->Merge(*numeric);
+  ASSERT_EQ(std::make_optional<int64_t>(2), stats->nan_count());
+  ASSERT_EQ(T{1}, stats->min());
+  ASSERT_EQ(T{1}, stats->max());
+}
+
+TEST(TestFloatStatistics, TotalOrder) {
+  // -qNaN(payload=1), +qNaN(payload=1).
+  TestNativeTotalOrder<FloatType>(uint32_t{0xffc00001}, uint32_t{0x7fc00001});
+  // -qNaN(payload=1), +qNaN(payload=1).
+  TestNativeTotalOrder<DoubleType>(uint64_t{0xfff8000000000001},
+                                   uint64_t{0x7ff8000000000001});
+}
+
+TEST(TestFloatStatistics, TotalOrderFloat16) {
+  // -qNaN(payload=1), +qNaN(payload=1).
+  BufferedFloat16 negative_nan(Float16::FromBits(0xfe01));

Review Comment:
   In the refactoring mentioned earlier, I removed `BufferedFloat16`. However, 
the issue where `FLBA` only stores pointers remains. I feel that accepting 
`Float16` might be a direction.
   
   Additionally, templates and `virtual` functions generally cannot coexist.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to