pitrou commented on code in PR #48459:
URL: https://github.com/apache/arrow/pull/48459#discussion_r2662281212


##########
cpp/src/arrow/compute/kernels/hash_aggregate.cc:
##########
@@ -276,46 +276,34 @@ struct AntiExtrema {
   static constexpr CType anti_max() { return 
std::numeric_limits<CType>::min(); }
 };
 
-template <>
-struct AntiExtrema<bool> {
-  static constexpr bool anti_min() { return true; }
-  static constexpr bool anti_max() { return false; }
+template <CBooleanConcept CType>
+struct AntiExtrema<CType> {
+  static constexpr CType anti_min() { return true; }
+  static constexpr CType anti_max() { return false; }
 };
 
-template <>
-struct AntiExtrema<float> {
-  static constexpr float anti_min() { return 
std::numeric_limits<float>::infinity(); }
-  static constexpr float anti_max() { return 
-std::numeric_limits<float>::infinity(); }
+template <CFloatingPointConcept CType>
+struct AntiExtrema<CType> {
+  static constexpr CType anti_min() { return 
std::numeric_limits<CType>::quiet_NaN(); }
+  static constexpr CType anti_max() { return 
std::numeric_limits<CType>::quiet_NaN(); }
 };
 
-template <>
-struct AntiExtrema<double> {
-  static constexpr double anti_min() { return 
std::numeric_limits<double>::infinity(); }
-  static constexpr double anti_max() { return 
-std::numeric_limits<double>::infinity(); }
+template <CDecimalConcept CType>
+struct AntiExtrema<CType> {
+  static constexpr CType anti_min() { return CType::GetMaxSentinel(); }
+  static constexpr CType anti_max() { return CType::GetMinSentinel(); }
 };
 
-template <>
-struct AntiExtrema<Decimal32> {
-  static constexpr Decimal32 anti_min() { return 
BasicDecimal32::GetMaxSentinel(); }
-  static constexpr Decimal32 anti_max() { return 
BasicDecimal32::GetMinSentinel(); }
-};
-
-template <>
-struct AntiExtrema<Decimal64> {
-  static constexpr Decimal64 anti_min() { return 
BasicDecimal64::GetMaxSentinel(); }
-  static constexpr Decimal64 anti_max() { return 
BasicDecimal64::GetMinSentinel(); }
-};
-
-template <>
-struct AntiExtrema<Decimal128> {
-  static constexpr Decimal128 anti_min() { return 
BasicDecimal128::GetMaxSentinel(); }
-  static constexpr Decimal128 anti_max() { return 
BasicDecimal128::GetMinSentinel(); }
+template <typename CType>
+struct MinMaxOp {
+  static constexpr CType min(CType a, CType b) { return std::min(a, b); }
+  static constexpr CType max(CType a, CType b) { return std::max(a, b); }
 };
 
-template <>
-struct AntiExtrema<Decimal256> {
-  static constexpr Decimal256 anti_min() { return 
BasicDecimal256::GetMaxSentinel(); }
-  static constexpr Decimal256 anti_max() { return 
BasicDecimal256::GetMinSentinel(); }
+template <CFloatingPointConcept CType>
+struct MinMaxOp<CType> {
+  static constexpr CType min(CType a, CType b) { return std::fmin(a, b); }
+  static constexpr CType max(CType a, CType b) { return std::fmax(a, b); }

Review Comment:
   Do `std::fmin/fmax` actually accept `util::Float16`??



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