From 99d90a1430437319ceab57e56c6bbd7cf594ede2 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 6 Nov 2023 01:58:20 +0100 Subject: [PATCH] Attempt to remove garbage --- .../AggregateFunctionSumMap.cpp | 50 ++++++++----------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/src/AggregateFunctions/AggregateFunctionSumMap.cpp b/src/AggregateFunctions/AggregateFunctionSumMap.cpp index ecc8a978388..f89af3a0dae 100644 --- a/src/AggregateFunctions/AggregateFunctionSumMap.cpp +++ b/src/AggregateFunctions/AggregateFunctionSumMap.cpp @@ -20,8 +20,19 @@ #include +namespace std +{ + template + struct hash> + { + size_t operator()(const DB::DecimalField & x) const { return hash()(x.getValue()); } + }; +} + + namespace DB { + struct Settings; namespace ErrorCodes @@ -65,7 +76,7 @@ struct AggregateFunctionMapData template class AggregateFunctionMapBase : public IAggregateFunctionDataHelper< - AggregateFunctionMapData>, Derived> + AggregateFunctionMapData, Derived> { private: static constexpr auto STATE_VERSION_1_MIN_REVISION = 54452; @@ -78,7 +89,7 @@ private: public: using Base = IAggregateFunctionDataHelper< - AggregateFunctionMapData>, Derived>; + AggregateFunctionMapData, Derived>; AggregateFunctionMapBase(const DataTypePtr & keys_type_, const DataTypes & values_types_, const DataTypes & argument_types_) @@ -227,15 +238,7 @@ public: continue; decltype(merged_maps.begin()) it; - if constexpr (is_decimal) - { - // FIXME why is storing NearestFieldType not enough, and we - // have to check for decimals again here? - UInt32 scale = static_cast &>(key_column).getScale(); - it = merged_maps.find(DecimalField(key, scale)); - } - else - it = merged_maps.find(key); + it = merged_maps.find(key); if (it != merged_maps.end()) { @@ -254,15 +257,7 @@ public: new_values.resize(size); new_values[col] = value; - if constexpr (is_decimal) - { - UInt32 scale = static_cast &>(key_column).getScale(); - merged_maps.emplace(DecimalField(key, scale), std::move(new_values)); - } - else - { - merged_maps.emplace(key, std::move(new_values)); - } + merged_maps.emplace(key, std::move(new_values)); } } } @@ -354,10 +349,7 @@ public: for (size_t col = 0; col < values_types.size(); ++col) deserialize(col, values); - if constexpr (is_decimal) - merged_maps[key.get>()] = values; - else - merged_maps[key.get()] = values; + merged_maps[key.get()] = values; } } @@ -711,7 +703,7 @@ auto parseArguments(const std::string & name, const DataTypes & arguments) // The template parameter MappedFunction is an aggregate // function template that allows to choose the aggregate function variant that // accepts either normal arguments or tuple argument. -template