refactor apercentile logs
This commit is contained in:
parent
21308d7853
commit
081695668d
|
@ -2494,6 +2494,8 @@ bool apercentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResult
|
||||||
} else {
|
} else {
|
||||||
buildHistogramInfo(pInfo);
|
buildHistogramInfo(pInfo);
|
||||||
pInfo->pHisto = tHistogramCreateFrom(tmp, MAX_HISTOGRAM_BIN);
|
pInfo->pHisto = tHistogramCreateFrom(tmp, MAX_HISTOGRAM_BIN);
|
||||||
|
qDebug("%s set up histogram, numOfElems:%" PRId64 ", numOfEntry:%d, pHisto:%p, elems:%p", __FUNCTION__,
|
||||||
|
pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -2524,6 +2526,9 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) {
|
||||||
tdigestAdd(pInfo->pTDigest, v, w);
|
tdigestAdd(pInfo->pTDigest, v, w);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
qDebug("%s before add %d elements into histogram, total:%d, numOfEntry:%d, pHisto:%p, elems: %p", __FUNCTION__,
|
||||||
|
numOfElems, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems);
|
||||||
|
|
||||||
for (int32_t i = start; i < pInput->numOfRows + start; ++i) {
|
for (int32_t i = start; i < pInput->numOfRows + start; ++i) {
|
||||||
if (colDataIsNull_f(pCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pCol->nullbitmap, i)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -2536,8 +2541,8 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) {
|
||||||
tHistogramAdd(&pInfo->pHisto, v);
|
tHistogramAdd(&pInfo->pHisto, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("add %d elements into histogram, total:%d, numOfEntry:%d, %p", numOfElems, pInfo->pHisto->numOfElems,
|
qDebug("%s after add %d elements into histogram, total:%d, numOfEntry:%d, pHisto:%p, elems: %p", __FUNCTION__,
|
||||||
pInfo->pHisto->numOfEntries, pInfo->pHisto);
|
numOfElems, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems);
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_VAL(pResInfo, numOfElems, 1);
|
SET_VAL(pResInfo, numOfElems, 1);
|
||||||
|
@ -2577,17 +2582,19 @@ static void apercentileTransferInfo(SAPercentileInfo* pInput, SAPercentileInfo*
|
||||||
memcpy(pHisto, pInput->pHisto, sizeof(SHistogramInfo) + sizeof(SHistBin) * (MAX_HISTOGRAM_BIN + 1));
|
memcpy(pHisto, pInput->pHisto, sizeof(SHistogramInfo) + sizeof(SHistBin) * (MAX_HISTOGRAM_BIN + 1));
|
||||||
pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo));
|
pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo));
|
||||||
|
|
||||||
qDebug("merge histo, total:%" PRId64 ", entry:%d, %p", pHisto->numOfElems, pHisto->numOfEntries, pHisto);
|
qDebug("%s merge histo, total:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems,
|
||||||
|
pHisto->numOfEntries, pHisto);
|
||||||
} else {
|
} else {
|
||||||
pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo));
|
pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo));
|
||||||
qDebug("input histogram, elem:%" PRId64 ", entry:%d, %p", pHisto->numOfElems, pHisto->numOfEntries,
|
qDebug("%s input histogram, elem:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems,
|
||||||
pInput->pHisto);
|
pHisto->numOfEntries, pInput->pHisto);
|
||||||
|
|
||||||
SHistogramInfo* pRes = tHistogramMerge(pHisto, pInput->pHisto, MAX_HISTOGRAM_BIN);
|
SHistogramInfo* pRes = tHistogramMerge(pHisto, pInput->pHisto, MAX_HISTOGRAM_BIN);
|
||||||
memcpy(pHisto, pRes, sizeof(SHistogramInfo) + sizeof(SHistBin) * MAX_HISTOGRAM_BIN);
|
memcpy(pHisto, pRes, sizeof(SHistogramInfo) + sizeof(SHistBin) * MAX_HISTOGRAM_BIN);
|
||||||
pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo));
|
pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo));
|
||||||
|
|
||||||
qDebug("merge histo, total:%" PRId64 ", entry:%d, %p", pHisto->numOfElems, pHisto->numOfEntries, pHisto);
|
qDebug("%s merge histo, total:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems,
|
||||||
|
pHisto->numOfEntries, pHisto);
|
||||||
tHistogramDestroy(&pRes);
|
tHistogramDestroy(&pRes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2603,7 +2610,7 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
SAPercentileInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
SAPercentileInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
qDebug("total %d rows will merge, %p", pInput->numOfRows, pInfo->pHisto);
|
qDebug("%s total %d rows will merge, %p", __FUNCTION__, pInput->numOfRows, pInfo->pHisto);
|
||||||
|
|
||||||
int32_t start = pInput->startRowIndex;
|
int32_t start = pInput->startRowIndex;
|
||||||
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
for (int32_t i = start; i < start + pInput->numOfRows; ++i) {
|
||||||
|
@ -2614,7 +2621,7 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->algo != APERCT_ALGO_TDIGEST) {
|
if (pInfo->algo != APERCT_ALGO_TDIGEST) {
|
||||||
qDebug("after merge, total:%d, numOfEntry:%d, %p", pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries,
|
qDebug("%s after merge, total:%d, numOfEntry:%d, %p", __FUNCTION__, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries,
|
||||||
pInfo->pHisto);
|
pInfo->pHisto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2637,8 +2644,8 @@ int32_t apercentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
} else {
|
} else {
|
||||||
buildHistogramInfo(pInfo);
|
buildHistogramInfo(pInfo);
|
||||||
if (pInfo->pHisto->numOfElems > 0) {
|
if (pInfo->pHisto->numOfElems > 0) {
|
||||||
qDebug("get the final res:%d, elements:%" PRId64 ", entry:%d", pInfo->pHisto->numOfElems,
|
qDebug("%s get the final res, elements:%" PRId64 ", numOfEntry:%d, pHisto:%p, elems:%p", __FUNCTION__,
|
||||||
pInfo->pHisto->numOfEntries);
|
pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems);
|
||||||
|
|
||||||
double ratio[] = {pInfo->percent};
|
double ratio[] = {pInfo->percent};
|
||||||
double* res = tHistogramUniform(pInfo->pHisto, ratio, 1);
|
double* res = tHistogramUniform(pInfo->pHisto, ratio, 1);
|
||||||
|
@ -2693,7 +2700,7 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx)
|
||||||
SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx);
|
SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx);
|
||||||
SAPercentileInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo);
|
SAPercentileInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo);
|
||||||
|
|
||||||
qDebug("start to combine apercentile, %p", pDBuf->pHisto);
|
qDebug("%s start to combine apercentile, %p", __FUNCTION__, pDBuf->pHisto);
|
||||||
|
|
||||||
apercentileTransferInfo(pSBuf, pDBuf);
|
apercentileTransferInfo(pSBuf, pDBuf);
|
||||||
pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes);
|
pDResInfo->numOfRes = TMAX(pDResInfo->numOfRes, pSResInfo->numOfRes);
|
||||||
|
|
Loading…
Reference in New Issue