提交 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) { ...@@ -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) { static void stddev_dst_function(SQLFunctionCtx *pCtx) {
SStddevdstInfo *pStd = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); SStddevdstInfo *pStd = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx));
...@@ -1505,7 +1516,7 @@ static void stddev_dst_function(SQLFunctionCtx *pCtx) { ...@@ -1505,7 +1516,7 @@ static void stddev_dst_function(SQLFunctionCtx *pCtx) {
SResPair* p = taosArrayGet(resList, 0); SResPair* p = taosArrayGet(resList, 0);
avg = p->avg; avg = p->avg;
} else { // todo opt performance by using iterator since the timestamp lsit is matched with the output result } 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) { if (p == NULL) {
return; return;
} }
......
...@@ -464,8 +464,8 @@ void taosFillSetInputDataBlock(SFillInfo* pFillInfo, const SSDataBlock* pInput) ...@@ -464,8 +464,8 @@ void taosFillSetInputDataBlock(SFillInfo* pFillInfo, const SSDataBlock* pInput)
pFillInfo->interval.slidingUnit, pFillInfo->interval.slidingUnit,
pFillInfo->precision); pFillInfo->precision);
numOfRes += 1; numOfRes += 1;
if(numOfRes < numOfRows) { if(numOfRes < numOfRows || pFillInfo->currentKey < lastKey) {
// reset current Key // set currentKey max
pFillInfo->currentKey = tsList[0]; pFillInfo->currentKey = tsList[0];
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册