提交 e5b1ba6d 编写于 作者: G Ganlin Zhao

add apercentile "t-digest" splitting

上级 6fff47b3
...@@ -1986,10 +1986,14 @@ static int8_t getApercentileAlgo(char *algoStr) { ...@@ -1986,10 +1986,14 @@ static int8_t getApercentileAlgo(char *algoStr) {
} }
static void buildHistogramInfo(SAPercentileInfo* pInfo) { static void buildHistogramInfo(SAPercentileInfo* pInfo) {
pInfo->pHisto = (SHistogramInfo*) ((char*) pInfo + sizeof(SAPercentileInfo)); pInfo->pHisto = (SHistogramInfo*) ((char*)pInfo + sizeof(SAPercentileInfo));
pInfo->pHisto->elems = (SHistBin*) ((char*)pInfo->pHisto + sizeof(SHistogramInfo)); pInfo->pHisto->elems = (SHistBin*) ((char*)pInfo->pHisto + sizeof(SHistogramInfo));
} }
static void buildTDigestInfo(SAPercentileInfo* pInfo) {
pInfo->pTDigest = (TDigest*)((char*)pInfo + sizeof(SAPercentileInfo));
}
bool apercentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) { bool apercentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) {
if (!functionSetup(pCtx, pResultInfo)) { if (!functionSetup(pCtx, pResultInfo)) {
return false; return false;
...@@ -2090,6 +2094,22 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) { ...@@ -2090,6 +2094,22 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) {
pInfo->percent = pInputInfo->percent; pInfo->percent = pInputInfo->percent;
pInfo->algo = pInputInfo->algo; pInfo->algo = pInputInfo->algo;
if (pInfo->algo == APERCT_ALGO_TDIGEST) { if (pInfo->algo == APERCT_ALGO_TDIGEST) {
buildTDigestInfo(pInputInfo);
tdigestAutoFill(pInputInfo->pTDigest, COMPRESSION);
if(pInputInfo->pTDigest->num_centroids == 0 && pInputInfo->pTDigest->num_buffered_pts == 0) {
return TSDB_CODE_SUCCESS;
}
buildTDigestInfo(pInfo);
TDigest *pTDigest = pInfo->pTDigest;
if(pTDigest->num_centroids <= 0) {
memcpy(pTDigest, pInputInfo->pTDigest, (size_t)TDIGEST_SIZE(COMPRESSION));
tdigestAutoFill(pTDigest, COMPRESSION);
} else {
tdigestMerge(pTDigest, pInputInfo->pTDigest);
}
} else { } else {
buildHistogramInfo(pInputInfo); buildHistogramInfo(pInputInfo);
if (pInputInfo->pHisto->numOfElems <= 0) { if (pInputInfo->pHisto->numOfElems <= 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册