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


##########
cpp/src/parquet/statistics.cc:
##########
@@ -349,6 +354,45 @@ struct CompareHelper<Float16LogicalType, 
/*is_signed=*/true> {
   }
 };
 
+float ToArrowFloat(float value) { return value; }
+
+double ToArrowFloat(double value) { return value; }
+
+Float16 ToArrowFloat(const FLBA& value) {
+  DCHECK_NE(value.ptr, nullptr);
+  return Float16::FromLittleEndian(value.ptr);
+}
+
+template <typename Int, typename T>
+std::strong_ordering TotalOrderCompareBits(T lhs, T rhs) {
+  // 
https://parquet.apache.org/blog/2026/05/29/taming-floating-point-statistics-in-apache-parquet-ieee-754-total-order-and-nan-counts/
+  auto lhs_bits = SafeCopy<Int>(lhs);
+  auto rhs_bits = SafeCopy<Int>(rhs);
+  using UInt = std::make_unsigned_t<Int>;
+  constexpr int sign_shift = sizeof(Int) * 8 - 1;
+  lhs_bits ^= static_cast<Int>(static_cast<UInt>(lhs_bits >> sign_shift) >> 1);
+  rhs_bits ^= static_cast<Int>(static_cast<UInt>(rhs_bits >> sign_shift) >> 1);
+  return lhs_bits <=> rhs_bits;

Review Comment:
   In C++20, it's not implementation-defined.



-- 
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