@@ -276,46 +276,34 @@ struct AntiExtrema {
276276 static constexpr CType anti_max () { return std::numeric_limits<CType>::min (); }
277277};
278278
279- template <>
280- struct AntiExtrema <bool > {
281- static constexpr bool anti_min () { return true ; }
282- static constexpr bool anti_max () { return false ; }
279+ template <CBooleanConcept CType >
280+ struct AntiExtrema <CType > {
281+ static constexpr CType anti_min () { return true ; }
282+ static constexpr CType anti_max () { return false ; }
283283};
284284
285- template <>
286- struct AntiExtrema <float > {
287- static constexpr float anti_min () { return std::numeric_limits<float >::infinity (); }
288- static constexpr float anti_max () { return - std::numeric_limits<float >::infinity (); }
285+ template <CFloatingPointConcept CType >
286+ struct AntiExtrema <CType > {
287+ static constexpr CType anti_min () { return std::numeric_limits<CType >::quiet_NaN (); }
288+ static constexpr CType anti_max () { return std::numeric_limits<CType >::quiet_NaN (); }
289289};
290290
291- template <>
292- struct AntiExtrema <double > {
293- static constexpr double anti_min () { return std::numeric_limits< double >:: infinity (); }
294- static constexpr double anti_max () { return -std::numeric_limits< double >:: infinity (); }
291+ template <CDecimalConcept CType >
292+ struct AntiExtrema <CType > {
293+ static constexpr CType anti_min () { return CType::GetMaxSentinel (); }
294+ static constexpr CType anti_max () { return CType::GetMinSentinel (); }
295295};
296296
297- template <>
298- struct AntiExtrema <Decimal32> {
299- static constexpr Decimal32 anti_min () { return BasicDecimal32::GetMaxSentinel (); }
300- static constexpr Decimal32 anti_max () { return BasicDecimal32::GetMinSentinel (); }
301- };
302-
303- template <>
304- struct AntiExtrema <Decimal64> {
305- static constexpr Decimal64 anti_min () { return BasicDecimal64::GetMaxSentinel (); }
306- static constexpr Decimal64 anti_max () { return BasicDecimal64::GetMinSentinel (); }
307- };
308-
309- template <>
310- struct AntiExtrema <Decimal128> {
311- static constexpr Decimal128 anti_min () { return BasicDecimal128::GetMaxSentinel (); }
312- static constexpr Decimal128 anti_max () { return BasicDecimal128::GetMinSentinel (); }
297+ template <typename CType>
298+ struct MinMaxOp {
299+ static constexpr CType min (CType a, CType b) { return std::min (a, b); }
300+ static constexpr CType max (CType a, CType b) { return std::max (a, b); }
313301};
314302
315- template <>
316- struct AntiExtrema <Decimal256 > {
317- static constexpr Decimal256 anti_min ( ) { return BasicDecimal256::GetMaxSentinel ( ); }
318- static constexpr Decimal256 anti_max ( ) { return BasicDecimal256::GetMinSentinel ( ); }
303+ template <CFloatingPointConcept CType >
304+ struct MinMaxOp <CType > {
305+ static constexpr CType min (CType a, CType b ) { return std::fmin (a, b ); }
306+ static constexpr CType max (CType a, CType b ) { return std::fmax (a, b ); }
319307};
320308
321309template <typename Type, typename Enable = void >
@@ -352,8 +340,8 @@ struct GroupedMinMaxImpl final : public GroupedAggregator {
352340 VisitGroupedValues<Type>(
353341 batch,
354342 [&](uint32_t g, CType val) {
355- GetSet::Set (raw_mins, g, std ::min (GetSet::Get (raw_mins, g), val));
356- GetSet::Set (raw_maxes, g, std ::max (GetSet::Get (raw_maxes, g), val));
343+ GetSet::Set (raw_mins, g, MinMaxOp<CType> ::min (GetSet::Get (raw_mins, g), val));
344+ GetSet::Set (raw_maxes, g, MinMaxOp<CType> ::max (GetSet::Get (raw_maxes, g), val));
357345 bit_util::SetBit (has_values_.mutable_data (), g);
358346 },
359347 [&](uint32_t g) { bit_util::SetBit (has_nulls_.mutable_data (), g); });
@@ -373,12 +361,12 @@ struct GroupedMinMaxImpl final : public GroupedAggregator {
373361 auto g = group_id_mapping.GetValues <uint32_t >(1 );
374362 for (uint32_t other_g = 0 ; static_cast <int64_t >(other_g) < group_id_mapping.length ;
375363 ++other_g, ++g) {
376- GetSet::Set (
377- raw_mins, *g,
378- std::min ( GetSet::Get (raw_mins, *g), GetSet::Get (other_raw_mins, other_g)));
379- GetSet::Set (
380- raw_maxes, *g,
381- std::max ( GetSet::Get (raw_maxes, *g), GetSet::Get (other_raw_maxes, other_g)));
364+ GetSet::Set (raw_mins, *g,
365+ MinMaxOp<CType>:: min ( GetSet::Get ( raw_mins, *g) ,
366+ GetSet::Get (other_raw_mins, other_g)));
367+ GetSet::Set (raw_maxes, *g,
368+ MinMaxOp<CType>:: max ( GetSet::Get ( raw_maxes, *g) ,
369+ GetSet::Get (other_raw_maxes, other_g)));
382370
383371 if (bit_util::GetBit (other->has_values_ .data (), other_g)) {
384372 bit_util::SetBit (has_values_.mutable_data (), *g);
0 commit comments