未验证 提交 72f6b934 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #18108 from taosdata/fix/TD-20366

fix: runtime error (division by zero in builtinsimpl.c)
......@@ -911,7 +911,7 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
case TSDB_DATA_TYPE_FLOAT: {
float* plist = (float*)pCol->pData;
// float val = 0;
// float val = 0;
for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) {
if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) {
continue;
......@@ -921,7 +921,7 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
pAvgRes->count += 1;
pAvgRes->sum.dsum += plist[i];
}
// pAvgRes->sum.dsum = val;
// pAvgRes->sum.dsum = val;
break;
}
......@@ -3011,7 +3011,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
}
}
#else
int64_t* pts = (int64_t*) pInput->pPTS->pData;
int64_t* pts = (int64_t*)pInput->pPTS->pData;
for (int32_t i = pInput->startRowIndex; i < pInput->startRowIndex + pInput->numOfRows; ++i) {
if (pInputCol->hasNull && colDataIsNull(pInputCol, pInput->totalRows, i, pColAgg)) {
continue;
......@@ -3179,7 +3179,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
}
// SET_VAL(pResInfo, numOfElems, 1);
// SET_VAL(pResInfo, numOfElems, 1);
return TSDB_CODE_SUCCESS;
}
......@@ -5280,7 +5280,6 @@ int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
return pInfo->numSampled;
}
bool getTailFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
#if 0
SColumnNode* pCol = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0);
......@@ -6077,11 +6076,19 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
int32_t row = 0;
char st[256] = {0};
double totalRawSize = pData->totalRows * pData->rowSize;
double averageSize = 0;
if (pData->numOfBlocks != 0) {
averageSize = ((double)pData->totalSize) / pData->numOfBlocks;
}
uint64_t totalRawSize = pData->totalRows * pData->rowSize;
double compRatio = 0;
if (totalRawSize != 0) {
compRatio = pData->totalSize * 100 / (double)totalRawSize;
}
int32_t len = sprintf(st + VARSTR_HEADER_SIZE,
"Total_Blocks=[%d] Total_Size=[%.2f Kb] Average_size=[%.2f Kb] Compression_Ratio=[%.2f %c]",
pData->numOfBlocks, pData->totalSize / 1024.0, ((double)pData->totalSize) / pData->numOfBlocks,
pData->totalSize * 100 / totalRawSize, '%');
pData->numOfBlocks, pData->totalSize / 1024.0, averageSize, compRatio, '%');
varDataSetLen(st, len);
colDataAppend(pColInfo, row++, st, false);
......
......@@ -321,7 +321,7 @@
,,y,script,./test.sh -f tsim/compress/compress.sim
,,y,script,./test.sh -f tsim/compress/uncompress.sim
,,y,script,./test.sh -f tsim/compute/avg.sim
,,,script,./test.sh -f tsim/compute/block_dist.sim
,,y,script,./test.sh -f tsim/compute/block_dist.sim
,,y,script,./test.sh -f tsim/compute/bottom.sim
,,y,script,./test.sh -f tsim/compute/count.sim
,,y,script,./test.sh -f tsim/compute/diff.sim
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册