Copilot commented on code in PR #50807:
URL: https://github.com/apache/arrow/pull/50807#discussion_r3850287222
##########
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:
`TotalOrderCompareBits` right-shifts signed integers (`lhs_bits >>
sign_shift`). Right-shifting a negative signed integer is
implementation-defined, so this can be non-portable across
compilers/architectures. Prefer deriving the sign mask using unsigned
operations only.
##########
cpp/src/parquet/schema.h:
##########
@@ -387,6 +387,8 @@ class PARQUET_EXPORT ColumnDescriptor {
switch (column_order().get_order()) {
case ColumnOrder::TYPE_DEFINED_ORDER:
return sort_order() != SortOrder::UNKNOWN;
+ case ColumnOrder::IEEE_754_TOTAL_ORDER:
+ return true;
Review Comment:
`ColumnDescriptor::can_use_min_max()` returns `true` for
`IEEE_754_TOTAL_ORDER` unconditionally, but `Comparator::Make(descr)` will
throw for non-floating physical/logical types. That makes `can_use_min_max()`
inconsistent with the actual supported comparisons (and can surface as
unexpected runtime exceptions if an in-memory schema sets IEEE order on a
non-float column).
--
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]