HuaHuaY commented on code in PR #50807:
URL: https://github.com/apache/arrow/pull/50807#discussion_r3804825381
##########
cpp/src/parquet/statistics.cc:
##########
@@ -349,6 +351,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;
+}
+
+std::strong_ordering TotalOrderCompare(float lhs, float rhs) {
+ static_assert(std::numeric_limits<float>::is_iec559);
+ // TODO: Use std::strong_order once all supported standard libraries
implement its
Review Comment:
I think it would be more convenient to use the standard library's
implementation if the standard library supports it.
--
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]