From 82241b3725a996c8b50373371ac019664028eacd Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Thu, 23 Apr 2020 17:44:36 +0800 Subject: [PATCH] [td-171] fix bugs in time filter in super table query. --- cmake/platform.inc | 2 +- src/client/src/tscSubquery.c | 2 +- src/query/src/queryExecutor.c | 16 +++++++--------- src/tsdb/src/tsdbRead.c | 21 ++++++++------------- src/util/src/talgo.c | 6 +++--- 5 files changed, 20 insertions(+), 27 deletions(-) diff --git a/cmake/platform.inc b/cmake/platform.inc index 2e0e2d6af0..1772a83fb2 100755 --- a/cmake/platform.inc +++ b/cmake/platform.inc @@ -62,7 +62,7 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) SET(TD_LINUX_64 TRUE) SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/linux) - ADD_DEFINITIONS(-D_M_X64) + ADD_DEFINITIONS(-D_M_X64 -D_DEBUG_VIEW) MESSAGE(STATUS "The current platform is Linux 64-bit") ELSEIF (${CMAKE_SIZEOF_VOID_P} MATCHES 4) IF (TD_ARM) diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index d17a490d57..b6d13554bb 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -1355,7 +1355,7 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR } #ifdef _DEBUG_VIEW - printf("received data from vnode: %d rows\n", pRes->numOfRows); + printf("received data from vnode: %"PRIu64" rows\n", pRes->numOfRows); SSrcColumnInfo colInfo[256] = {0}; tscGetSrcColumnInfo(colInfo, pQueryInfo); diff --git a/src/query/src/queryExecutor.c b/src/query/src/queryExecutor.c index f7a82e4040..1f4ab09419 100644 --- a/src/query/src/queryExecutor.c +++ b/src/query/src/queryExecutor.c @@ -1036,9 +1036,8 @@ static int32_t doTSJoinFilter(SQueryRuntimeEnv *pRuntimeEnv, int32_t offset) { TSKEY key = *(TSKEY *)(pCtx[0].aInputElemBuf + TSDB_KEYSIZE * offset); #if defined(_DEBUG_VIEW) - printf("elem in comp ts file:%" PRId64 ", key:%" PRId64 - ", tag:%d, id:%s, query order:%d, ts order:%d, traverse:%d, index:%d\n", - elem.ts, key, elem.tag, pRuntimeEnv->pTabObj->meterId, pQuery->order.order, pRuntimeEnv->pTSBuf->tsOrder, + printf("elem in comp ts file:%" PRId64 ", key:%" PRId64 ", tag:%"PRIu64", query order:%d, ts order:%d, traverse:%d, index:%d\n", + elem.ts, key, elem.tag, pQuery->order.order, pRuntimeEnv->pTSBuf->tsOrder, pRuntimeEnv->pTSBuf->cur.order, pRuntimeEnv->pTSBuf->cur.tsIndex); #endif @@ -2312,8 +2311,7 @@ SArray *loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pBl */ if (!needToLoadDataBlock(pQuery, *pStatis, pRuntimeEnv->pCtx, pBlockInfo->rows)) { #if defined(_DEBUG_VIEW) - qTrace("QInfo:%p fileId:%d, slot:%d, block discarded by per-filter", GET_QINFO_ADDR(pQuery), pQuery->fileId, - pQuery->slot); + qTrace("QInfo:%p block discarded by per-filter", GET_QINFO_ADDR(pRuntimeEnv)); #endif // return DISK_DATA_DISCARDED; } @@ -2946,7 +2944,7 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) { int64_t endt = taosGetTimestampMs(); #ifdef _DEBUG_VIEW - displayInterResult(pQuery->sdata, pQuery, pQuery->sdata[0]->len); + displayInterResult(pQuery->sdata, pQuery, pQuery->sdata[0]->num); #endif qTrace("QInfo:%p result merge completed, elapsed time:%" PRId64 " ms", GET_QINFO_ADDR(pQuery), endt - startt); @@ -4337,7 +4335,7 @@ static int64_t queryOnDataBlocks(SQInfo *pQInfo) { SDataStatis *pStatis = NULL; SArray * pDataBlock = loadDataBlockOnDemand(pRuntimeEnv, &blockInfo, &pStatis); - TSKEY nextKey = blockInfo.window.ekey; + TSKEY nextKey = blockInfo.window.skey; if (!isIntervalQuery(pQuery)) { setExecutionContext(pQInfo, pTableQueryInfo, pTable, pTableDataInfo->groupIdx, nextKey); } else { // interval query @@ -4784,7 +4782,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) { copyResToQueryResultBuf(pQInfo, pQuery); #ifdef _DEBUG_VIEW - displayInterResult(pQuery->sdata, pQuery, pQuery->sdata[0]->len); + displayInterResult(pQuery->sdata, pQuery, pQuery->sdata[0]->num); #endif } else { copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult); @@ -4845,7 +4843,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) { copyResToQueryResultBuf(pQInfo, pQuery); #ifdef _DEBUG_VIEW - displayInterResult(pQuery->sdata, pQuery, pQuery->sdata[0]->len); + displayInterResult(pQuery->sdata, pQuery, pQuery->sdata[0]->num); #endif } } else { // not a interval query diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 2f644175a5..531a9e3b88 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -442,11 +442,13 @@ static bool loadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock if (!doLoadFileDataBlock(pQueryHandle, pBlock, pCheckInfo)) { return false; } - - SDataCols* pDataCols = pCheckInfo->pDataCols; + + SDataCols* pCols = pQueryHandle->rhelper.pDataCols[0]; + assert(pCols->numOfPoints == pBlock->numOfPoints); + if (pCheckInfo->lastKey > pBlock->keyFirst) { cur->pos = - binarySearchForKey(pDataCols->cols[0].pData, pBlock->numOfPoints, pCheckInfo->lastKey, pQueryHandle->order); + binarySearchForKey(pCols->cols[0].pData, pBlock->numOfPoints, pCheckInfo->lastKey, pQueryHandle->order); } else { cur->pos = 0; } @@ -548,8 +550,9 @@ static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInf SArray* sa) { SQueryFilePos* cur = &pQueryHandle->cur; SDataBlockInfo blockInfo = getTrueDataBlockInfo(pCheckInfo, pBlock); - - SDataCols* pCols = pCheckInfo->pDataCols; + +// pQueryHandle->rhelper.pDataCols[0]->cols[0]; + SDataCols* pCols = pQueryHandle->rhelper.pDataCols[0]; int32_t endPos = cur->pos; if (ASCENDING_ORDER_TRAVERSE(pQueryHandle->order) && pQueryHandle->window.ekey > blockInfo.window.ekey) { @@ -1335,10 +1338,6 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC taosArrayPush(pTableGroup, &sa); uTrace("all %d tables belong to one group", size); - -#ifdef _DEBUG_VIEW - tSidSetDisplay(pTableGroup); -#endif } else { STableGroupSupporter *pSupp = (STableGroupSupporter *) calloc(1, sizeof(STableGroupSupporter)); pSupp->numOfCols = numOfOrderCols; @@ -1347,10 +1346,6 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC taosqsort(pTableList->pData, size, POINTER_BYTES, pSupp, tableGroupComparFn); createTableGroupImpl(pTableGroup, pTableList->pData, size, pSupp, tableGroupComparFn); - -#ifdef _DEBUG_VIEW - tSidSetDisplay(pTableGroup); -#endif tfree(pSupp); } diff --git a/src/util/src/talgo.c b/src/util/src/talgo.c index 76de87e67d..32978453fc 100644 --- a/src/util/src/talgo.c +++ b/src/util/src/talgo.c @@ -42,9 +42,9 @@ static void median(void *src, size_t size, size_t s, size_t e, const void *param assert(comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) <= 0 && comparFn(elePtrAt(src, size, s), elePtrAt(src, size, e), param) <= 0); #ifdef _DEBUG_VIEW - tTagsPrints(src[s], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx); - tTagsPrints(src[mid], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx); - tTagsPrints(src[e], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx); +// tTagsPrints(src[s], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx); +// tTagsPrints(src[mid], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx); +// tTagsPrints(src[e], pOrderDesc->pColumnModel, &pOrderDesc->orderIdx); #endif } -- GitLab