Merge branch 'feature/query' of github.com:taosdata/TDengine into feature/query
This commit is contained in:
commit
49c19cbd1f
|
@ -847,18 +847,32 @@ static int32_t getNextQualifiedWindow(SQueryRuntimeEnv *pRuntimeEnv, STimeWindow
|
|||
}
|
||||
|
||||
int32_t startPos = 0;
|
||||
|
||||
// tumbling time window query, a special case of sliding time window query
|
||||
if (pQuery->interval.sliding == pQuery->interval.interval && prevPosition != -1) {
|
||||
int32_t factor = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order);
|
||||
startPos = prevPosition + factor;
|
||||
} else {
|
||||
if (startKey < pDataBlockInfo->window.skey && QUERY_IS_ASC_QUERY(pQuery)) {
|
||||
startPos = 0;
|
||||
} else if (startKey > pDataBlockInfo->window.ekey && !QUERY_IS_ASC_QUERY(pQuery)) {
|
||||
startPos = pDataBlockInfo->rows - 1;
|
||||
} else {
|
||||
startPos = searchFn((char *)primaryKeys, pDataBlockInfo->rows, startKey, pQuery->order.order);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This time window does not cover any data, try next time window,
|
||||
* this case may happen when the time window is too small
|
||||
*/
|
||||
if (primaryKeys == NULL) {
|
||||
if (QUERY_IS_ASC_QUERY(pQuery)) {
|
||||
assert(pDataBlockInfo->window.skey <= pNext->ekey);
|
||||
} else {
|
||||
assert(pDataBlockInfo->window.ekey >= pNext->skey);
|
||||
}
|
||||
} else {
|
||||
if (QUERY_IS_ASC_QUERY(pQuery) && primaryKeys[startPos] > pNext->ekey) {
|
||||
TSKEY next = primaryKeys[startPos];
|
||||
if (pQuery->interval.intervalUnit == 'n' || pQuery->interval.intervalUnit == 'y') {
|
||||
|
@ -878,6 +892,7 @@ static int32_t getNextQualifiedWindow(SQueryRuntimeEnv *pRuntimeEnv, STimeWindow
|
|||
pNext->ekey = pNext->skey + pQuery->interval.interval - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return startPos;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue