From aa03712b6d5b6371d64b2a95f32d8f5a7a39fd83 Mon Sep 17 00:00:00 2001 From: Bharat Nallan Chakravarthy Date: Wed, 14 Dec 2022 23:49:51 -0800 Subject: [PATCH] fix build failure --- ...teFunctionQuantileInterpolatedWeighted.cpp | 1 - .../QuantileInterpolatedWeighted.h | 46 ++++++++++++------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/AggregateFunctions/AggregateFunctionQuantileInterpolatedWeighted.cpp b/src/AggregateFunctions/AggregateFunctionQuantileInterpolatedWeighted.cpp index c4636182262..68b42376df7 100644 --- a/src/AggregateFunctions/AggregateFunctionQuantileInterpolatedWeighted.cpp +++ b/src/AggregateFunctions/AggregateFunctionQuantileInterpolatedWeighted.cpp @@ -53,7 +53,6 @@ namespace throw Exception("Illegal type " + argument_type->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); } - } void registerAggregateFunctionsQuantileInterpolatedWeighted(AggregateFunctionFactory & factory) diff --git a/src/AggregateFunctions/QuantileInterpolatedWeighted.h b/src/AggregateFunctions/QuantileInterpolatedWeighted.h index f2e00dac973..cd6ae0473e3 100644 --- a/src/AggregateFunctions/QuantileInterpolatedWeighted.h +++ b/src/AggregateFunctions/QuantileInterpolatedWeighted.h @@ -75,8 +75,31 @@ struct QuantileInterpolatedWeighted } } - /// Get the value of the `level` quantile. The level must be between 0 and 1. Value get(Float64 level) const + { + return getImpl(level); + } + + void getMany(const Float64 * levels, const size_t * indices, size_t size, Value * result) const + { + getManyImpl(levels, indices, size, result); + } + + /// The same, but in the case of an empty state, NaN is returned. + Float64 getFloat(Float64) const + { + throw Exception("Method getFloat is not implemented for QuantileInterpolatedWeighted", ErrorCodes::NOT_IMPLEMENTED); + } + + void getManyFloat(const Float64 *, const size_t *, size_t, Float64 *) const + { + throw Exception("Method getManyFloat is not implemented for QuantileInterpolatedWeighted", ErrorCodes::NOT_IMPLEMENTED); + } + +private: + /// Get the value of the `level` quantile. The level must be between 0 and 1. + template + T getImpl(Float64 level) const { size_t size = map.size(); @@ -164,13 +187,13 @@ struct QuantileInterpolatedWeighted if (level > xr) yl = yr; - return interpolate(level, xl, xr, yl, yr); + return static_cast(interpolate(level, xl, xr, yl, yr)); } - /// Get the `size` values of `levels` quantiles. Write `size` results starting with `result` address. /// indices - an array of index levels such that the corresponding elements will go in ascending order. - void getMany(const Float64 * levels, const size_t * indices, size_t num_levels, Value * result) const + template + void getManyImpl(const Float64 * levels, const size_t * indices, size_t num_levels, Value * result) const { size_t size = map.size(); @@ -258,7 +281,7 @@ struct QuantileInterpolatedWeighted if (level > xr) yl = yr; - result[indices[level_index]] = interpolate(level, xl, xr, yl, yr); + result[indices[level_index]] = static_cast(interpolate(level, xl, xr, yl, yr)); ++level_index; } } @@ -272,21 +295,10 @@ struct QuantileInterpolatedWeighted dx = dx == 0 ? 1 : dx; /// to handle NaN behavior that might arise during integer division below. /// yl + (dy / dx) * (level - xl) - UnderlyingType g = common::addIgnoreOverflow(yl, common::mulIgnoreOverflow((dy / dx), common::subIgnoreOverflow(level, xl))); + UnderlyingType g = static_cast(common::addIgnoreOverflow(yl, common::mulIgnoreOverflow((dy / dx), common::subIgnoreOverflow(level, xl)))); return g; } - - /// The same, but in the case of an empty state, NaN is returned. - Float64 getFloat(Float64) const - { - throw Exception("Method getFloat is not implemented for QuantileInterpolatedWeighted", ErrorCodes::NOT_IMPLEMENTED); - } - - void getManyFloat(const Float64 *, const size_t *, size_t, Float64 *) const - { - throw Exception("Method getManyFloat is not implemented for QuantileInterpolatedWeighted", ErrorCodes::NOT_IMPLEMENTED); - } }; }