[td-1067]
This commit is contained in:
parent
51290fd1aa
commit
e4e4c7fcd3
|
@ -97,7 +97,8 @@ typedef struct {
|
||||||
#if 0
|
#if 0
|
||||||
static UNUSED_FUNC void *u_malloc (size_t __size) {
|
static UNUSED_FUNC void *u_malloc (size_t __size) {
|
||||||
uint32_t v = rand();
|
uint32_t v = rand();
|
||||||
if (v % 5 <= 1) {
|
|
||||||
|
if (v % 1000 <= 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
return malloc(__size);
|
return malloc(__size);
|
||||||
|
@ -106,7 +107,7 @@ static UNUSED_FUNC void *u_malloc (size_t __size) {
|
||||||
|
|
||||||
static UNUSED_FUNC void* u_calloc(size_t num, size_t __size) {
|
static UNUSED_FUNC void* u_calloc(size_t num, size_t __size) {
|
||||||
uint32_t v = rand();
|
uint32_t v = rand();
|
||||||
if (v % 5 <= 1) {
|
if (v % 1000 <= 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
return calloc(num, __size);
|
return calloc(num, __size);
|
||||||
|
@ -1887,16 +1888,12 @@ static void changeExecuteScanOrder(SQInfo *pQInfo, bool stableQuery) {
|
||||||
// descending order query for last_row query
|
// descending order query for last_row query
|
||||||
if (isFirstLastRowQuery(pQuery)) {
|
if (isFirstLastRowQuery(pQuery)) {
|
||||||
qDebug("QInfo:%p scan order changed for last_row query, old:%d, new:%d", GET_QINFO_ADDR(pQuery),
|
qDebug("QInfo:%p scan order changed for last_row query, old:%d, new:%d", GET_QINFO_ADDR(pQuery),
|
||||||
pQuery->order.order, TSDB_ORDER_DESC);
|
pQuery->order.order, TSDB_ORDER_ASC);
|
||||||
|
|
||||||
pQuery->order.order = TSDB_ORDER_DESC;
|
|
||||||
|
|
||||||
int64_t skey = MIN(pQuery->window.skey, pQuery->window.ekey);
|
|
||||||
int64_t ekey = MAX(pQuery->window.skey, pQuery->window.ekey);
|
|
||||||
|
|
||||||
pQuery->window.skey = ekey;
|
|
||||||
pQuery->window.ekey = skey;
|
|
||||||
|
|
||||||
|
pQuery->order.order = TSDB_ORDER_ASC;
|
||||||
|
if (pQuery->window.skey > pQuery->window.ekey) {
|
||||||
|
SWAP(pQuery->window.skey, pQuery->window.ekey, TSKEY);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4316,30 +4313,18 @@ static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery)
|
||||||
// update the query time window
|
// update the query time window
|
||||||
pQuery->window = cond.twindow;
|
pQuery->window = cond.twindow;
|
||||||
|
|
||||||
int32_t numOfGroups = (int32_t)(GET_NUM_OF_TABLEGROUP(pQInfo));
|
size_t numOfGroups = GET_NUM_OF_TABLEGROUP(pQInfo);
|
||||||
|
|
||||||
for(int32_t i = 0; i < numOfGroups; ++i) {
|
for(int32_t i = 0; i < numOfGroups; ++i) {
|
||||||
SArray *group = GET_TABLEGROUP(pQInfo, i);
|
SArray *group = GET_TABLEGROUP(pQInfo, i);
|
||||||
SArray *tableKeyGroup = taosArrayGetP(pQInfo->tableGroupInfo.pGroupList, i);
|
|
||||||
|
|
||||||
size_t t = taosArrayGetSize(group);
|
size_t t = taosArrayGetSize(group);
|
||||||
for (int32_t j = 0; j < t; ++j) {
|
for (int32_t j = 0; j < t; ++j) {
|
||||||
STableQueryInfo *pCheckInfo = taosArrayGetP(group, j);
|
STableQueryInfo *pCheckInfo = taosArrayGetP(group, j);
|
||||||
updateTableQueryInfoForReverseScan(pQuery, pCheckInfo);
|
|
||||||
|
|
||||||
// update the last key in tableKeyInfo list, the tableKeyInfo is used to build the tsdbQueryHandle and decide
|
pCheckInfo->win = pQuery->window;
|
||||||
// the start check timestamp of tsdbQueryHandle
|
pCheckInfo->lastKey = pCheckInfo->win.skey;
|
||||||
STableKeyInfo *pTableKeyInfo = taosArrayGet(tableKeyGroup, j);
|
|
||||||
pCheckInfo->win.skey = pTableKeyInfo->lastKey;
|
|
||||||
pCheckInfo->win.ekey = pTableKeyInfo->lastKey;
|
|
||||||
|
|
||||||
pCheckInfo->lastKey = pTableKeyInfo->lastKey;
|
|
||||||
|
|
||||||
assert(pCheckInfo->pTable == pTableKeyInfo->pTable);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else if (isPointInterpoQuery(pQuery)) {
|
} else if (isPointInterpoQuery(pQuery)) {
|
||||||
pRuntimeEnv->pQueryHandle = tsdbQueryRowsInExternalWindow(tsdb, &cond, &pQInfo->tableGroupInfo, pQInfo);
|
pRuntimeEnv->pQueryHandle = tsdbQueryRowsInExternalWindow(tsdb, &cond, &pQInfo->tableGroupInfo, pQInfo);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -295,12 +295,8 @@ out_of_memory:
|
||||||
}
|
}
|
||||||
|
|
||||||
TsdbQueryHandleT tsdbQueryLastRow(TSDB_REPO_T *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupList, void* qinfo) {
|
TsdbQueryHandleT tsdbQueryLastRow(TSDB_REPO_T *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupList, void* qinfo) {
|
||||||
pCond->order = TSDB_ORDER_DESC;
|
pCond->order = TSDB_ORDER_ASC;
|
||||||
pCond->twindow = changeTableGroupByLastrow(groupList);
|
pCond->twindow = changeTableGroupByLastrow(groupList);
|
||||||
|
|
||||||
//descending order query, skey >= ekey
|
|
||||||
SWAP(pCond->twindow.skey, pCond->twindow.ekey, TSKEY);
|
|
||||||
|
|
||||||
STsdbQueryHandle *pQueryHandle = (STsdbQueryHandle*) tsdbQueryTables(tsdb, pCond, groupList, qinfo);
|
STsdbQueryHandle *pQueryHandle = (STsdbQueryHandle*) tsdbQueryTables(tsdb, pCond, groupList, qinfo);
|
||||||
return pQueryHandle;
|
return pQueryHandle;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue