diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index e904ac62de64783c14ea970476a280af1bbecc44..fd8b2c68f11e15fe0788b99a24b6fedce5bea5ef 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -1808,7 +1808,7 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { bool getApercentileFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { int32_t bytesHist = (int32_t)(sizeof(SAPercentileInfo) + sizeof(SHistogramInfo) + sizeof(SHistBin) * (MAX_HISTOGRAM_BIN + 1)); int32_t bytesDigest = (int32_t)(sizeof(SAPercentileInfo) + TDIGEST_SIZE(COMPRESSION)); - pEnv->calcMemSize = MAX(bytesHist, bytesDigest); + pEnv->calcMemSize = TMAX(bytesHist, bytesDigest); return true; } diff --git a/source/util/src/tdigest.c b/source/util/src/tdigest.c index 0e1dcbe29f5afbfacc4715f0cd14c4d220d9b0b4..56b113fd8f166aae397e05ef3fed40e4df00309a 100644 --- a/source/util/src/tdigest.c +++ b/source/util/src/tdigest.c @@ -97,8 +97,8 @@ static void mergeCentroid(SMergeArgs *args, SCentroid *merge) { c->mean += (merge->mean - c->mean) * merge->weight / c->weight; if (merge->weight > 0) { - args->min = MIN(merge->mean, args->min); - args->max = MAX(merge->mean, args->max); + args->min = TMIN(merge->mean, args->min); + args->max = TMAX(merge->mean, args->max); } } } @@ -162,12 +162,12 @@ void tdigestCompress(TDigest *t) { } if (t->total_weight > 0) { - t->min = MIN(t->min, args.min); + t->min = TMIN(t->min, args.min); if (args.centroids[args.idx].weight <= 0) { args.idx--; } t->num_centroids = args.idx + 1; - t->max = MAX(t->max, args.max); + t->max = TMAX(t->max, args.max); } memcpy(t->centroids, args.centroids, sizeof(SCentroid) * t->num_centroids); @@ -234,7 +234,7 @@ double tdigestCDF(TDigest *t, double x) { + a->weight * INTERPOLATE(x, a->mean - left, a->mean + right)) / t->total_weight; - return MAX(cdf, 0.0); + return TMAX(cdf, 0.0); } weight_so_far += a->weight;