diff --git a/dbms/src/AggregateFunctions/AggregateFunctionStatistics.h b/dbms/src/AggregateFunctions/AggregateFunctionStatistics.h index b7d653e35f8..03a968d37bb 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionStatistics.h +++ b/dbms/src/AggregateFunctions/AggregateFunctionStatistics.h @@ -350,16 +350,12 @@ public: Base::deserialize(buf); } - template - void publish(IColumn & to, typename std::enable_if::type * = nullptr) const + void publish(IColumn & to) const { - static_cast(to).getData().push_back(Op::apply(co_moment, Base::left_m2, Base::right_m2, count)); - } - - template - void publish(IColumn & to, typename std::enable_if::type * = nullptr) const - { - static_cast(to).getData().push_back(Op::apply(co_moment, count)); + if constexpr (compute_marginal_moments) + static_cast(to).getData().push_back(Op::apply(co_moment, Base::left_m2, Base::right_m2, count)); + else + static_cast(to).getData().push_back(Op::apply(co_moment, count)); } private: diff --git a/dbms/src/AggregateFunctions/AggregateFunctionUniq.h b/dbms/src/AggregateFunctions/AggregateFunctionUniq.h index bf99f0081a2..a3d8552eb0f 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionUniq.h +++ b/dbms/src/AggregateFunctions/AggregateFunctionUniq.h @@ -273,81 +273,63 @@ template <> struct AggregateFunctionUniqCombinedTraits } }; + /** The structure for the delegation work to add one element to the `uniq` aggregate functions. * Used for partial specialization to add strings. */ -template -struct OneAdder; - template -struct OneAdder::value || - std::is_same>::value>::type> +struct OneAdder { - template - static void ALWAYS_INLINE addImpl(Data & data, const IColumn & column, size_t row_num, - typename std::enable_if::value>::type * = nullptr) + static void ALWAYS_INLINE addImpl(Data & data, const IColumn & column, size_t row_num) { - const auto & value = static_cast &>(column).getData()[row_num]; - data.set.insert(AggregateFunctionUniqTraits::hash(value)); - } + if constexpr (std::is_same::value + || std::is_same>::value) + { + if constexpr (!std::is_same::value) + { + const auto & value = static_cast &>(column).getData()[row_num]; + data.set.insert(AggregateFunctionUniqTraits::hash(value)); + } + else + { + StringRef value = column.getDataAt(row_num); + data.set.insert(CityHash_v1_0_2::CityHash64(value.data, value.size)); + } + } + else if constexpr (std::is_same>::value + || std::is_same>::value + || std::is_same>::value + || std::is_same>::value) + { + if constexpr (!std::is_same::value) + { + const auto & value = static_cast &>(column).getData()[row_num]; + data.set.insert(AggregateFunctionUniqCombinedTraits::hash(value)); + } + else + { + StringRef value = column.getDataAt(row_num); + data.set.insert(CityHash_v1_0_2::CityHash64(value.data, value.size)); + } + } + else if constexpr (std::is_same>::value) + { + if constexpr (!std::is_same::value) + { + data.set.insert(static_cast &>(column).getData()[row_num]); + } + else + { + StringRef value = column.getDataAt(row_num); - template - static void ALWAYS_INLINE addImpl(Data & data, const IColumn & column, size_t row_num, - typename std::enable_if::value>::type * = nullptr) - { - StringRef value = column.getDataAt(row_num); - data.set.insert(CityHash_v1_0_2::CityHash64(value.data, value.size)); - } -}; + UInt128 key; + SipHash hash; + hash.update(value.data, value.size); + hash.get128(key.low, key.high); -template -struct OneAdder>::value || - std::is_same>::value || - std::is_same>::value || - std::is_same>::value>::type> -{ - template - static void ALWAYS_INLINE addImpl(Data & data, const IColumn & column, size_t row_num, - typename std::enable_if::value>::type * = nullptr) - { - const auto & value = static_cast &>(column).getData()[row_num]; - data.set.insert(AggregateFunctionUniqCombinedTraits::hash(value)); - } - - template - static void ALWAYS_INLINE addImpl(Data & data, const IColumn & column, size_t row_num, - typename std::enable_if::value>::type * = nullptr) - { - StringRef value = column.getDataAt(row_num); - data.set.insert(CityHash_v1_0_2::CityHash64(value.data, value.size)); - } -}; - -template -struct OneAdder>::value>::type> -{ - template - static void ALWAYS_INLINE addImpl(Data & data, const IColumn & column, size_t row_num, - typename std::enable_if::value>::type * = nullptr) - { - data.set.insert(static_cast &>(column).getData()[row_num]); - } - - template - static void ALWAYS_INLINE addImpl(Data & data, const IColumn & column, size_t row_num, - typename std::enable_if::value>::type * = nullptr) - { - StringRef value = column.getDataAt(row_num); - - UInt128 key; - SipHash hash; - hash.update(value.data, value.size); - hash.get128(key.low, key.high); - - data.set.insert(key); + data.set.insert(key); + } + } } }; diff --git a/dbms/src/DataStreams/UnionBlockInputStream.h b/dbms/src/DataStreams/UnionBlockInputStream.h index 8f24235b60c..60639002e9f 100644 --- a/dbms/src/DataStreams/UnionBlockInputStream.h +++ b/dbms/src/DataStreams/UnionBlockInputStream.h @@ -237,17 +237,13 @@ protected: } private: - template - BlockExtraInfo doGetBlockExtraInfo(typename std::enable_if::type * = nullptr) const + BlockExtraInfo doGetBlockExtraInfo() const { - return received_payload.extra_info; - } - - template - BlockExtraInfo doGetBlockExtraInfo(typename std::enable_if::type * = nullptr) const - { - throw Exception("Method getBlockExtraInfo is not supported for mode StreamUnionMode::Basic", - ErrorCodes::NOT_IMPLEMENTED); + if constexpr (mode == StreamUnionMode::ExtraInfo) + return received_payload.extra_info; + else + throw Exception("Method getBlockExtraInfo is not supported for mode StreamUnionMode::Basic", + ErrorCodes::NOT_IMPLEMENTED); } private: