提交 1e503061 编写于 作者: G Ganlin Zhao

feat(query): add mavg function

上级 8d21c662
...@@ -3013,18 +3013,22 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx) { ...@@ -3013,18 +3013,22 @@ int32_t mavgFunction(SqlFunctionCtx* pCtx) {
} else { } else {
pInfo->sum = pInfo->sum + v - pInfo->points[pInfo->pos]; pInfo->sum = pInfo->sum + v - pInfo->points[pInfo->pos];
} }
}
pInfo->points[pInfo->pos] = v; pInfo->points[pInfo->pos] = v;
double result = pInfo->sum / pInfo->numOfPoints; double result = pInfo->sum / pInfo->numOfPoints;
colDataAppend(pOutput, pos, (char *)&result, false); colDataAppend(pOutput, pos, (char *)&result, false);
//TODO: remove this after pTsOutput is handled //TODO: remove this after pTsOutput is handled
if (pTsOutput != NULL) { if (pTsOutput != NULL) {
colDataAppendInt64(pTsOutput, pos, &tsList[i]); colDataAppendInt64(pTsOutput, pos, &tsList[i]);
}
numOfElems++;
} }
numOfElems++; pInfo->pos++;
if (pInfo->pos == pInfo->numOfPoints) {
pInfo->pos = 0;
}
} }
return numOfElems; return numOfElems;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册