提交 86d89603 编写于 作者: A Alex Duan

fix(query): stddev order by desc supported and bsearch order by desc supported

上级 f5f3cad6
......@@ -1484,6 +1484,17 @@ int32_t tsCompare(const void* p1, const void* p2) {
}
}
int32_t tsCompareDesc(const void* p1, const void* p2) {
TSKEY k = *(TSKEY*)p1;
SResPair* pair = (SResPair*)p2;
if (k == pair->key) {
return 0;
} else {
return k > pair->key? -1:1;
}
}
static void stddev_dst_function(SQLFunctionCtx *pCtx) {
SStddevdstInfo *pStd = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
......@@ -1505,7 +1516,7 @@ static void stddev_dst_function(SQLFunctionCtx *pCtx) {
SResPair* p = taosArrayGet(resList, 0);
avg = p->avg;
} else { // todo opt performance by using iterator since the timestamp lsit is matched with the output result
SResPair* p = bsearch(&pCtx->startTs, resList->pData, len, sizeof(SResPair), tsCompare);
SResPair* p = bsearch(&pCtx->startTs, resList->pData, len, sizeof(SResPair), pCtx->order == TSDB_ORDER_DESC ? tsCompareDesc : tsCompare);
if (p == NULL) {
return;
}
......
......@@ -464,8 +464,8 @@ void taosFillSetInputDataBlock(SFillInfo* pFillInfo, const SSDataBlock* pInput)
pFillInfo->interval.slidingUnit,
pFillInfo->precision);
numOfRes += 1;
if(numOfRes < numOfRows) {
// reset current Key
if(numOfRes < numOfRows || pFillInfo->currentKey < lastKey) {
// set currentKey max
pFillInfo->currentKey = tsList[0];
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册