diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 57a6645215..5b417999b4 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -741,8 +741,6 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis int32_t len = (int32_t)(pStart - (char*)keyBuf); info->groupId = calcGroupId(keyBuf, len); - - taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &i, sizeof(int32_t)); } // int64_t st2 = taosGetTimestampUs(); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index b5c6c5cf39..e31a34e5ad 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -3379,7 +3379,7 @@ static int32_t sortTableGroup(STableListInfo* pTableListInfo) { int32_t code = TSDB_CODE_SUCCESS; taosArraySort(pTableListInfo->pTableList, orderbyGroupIdComparFn); - int32_t size = getTotalTables(pTableListInfo); + int32_t size = taosArrayGetSize(pTableListInfo->pTableList); SArray* pList = taosArrayInit(4, sizeof(int32_t)); @@ -3403,7 +3403,6 @@ static int32_t sortTableGroup(STableListInfo* pTableListInfo) { taosArrayDestroy(pList); # if 0 - SArray* sortSupport = taosArrayInit(16, sizeof(uint64_t)); if (sortSupport == NULL) { return TSDB_CODE_OUT_OF_MEMORY; @@ -3504,13 +3503,12 @@ int32_t setGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle* p for (int32_t i = 0; i < numOfTables; i++) { STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i); info->groupId = groupByTbname? info->uid:0; - - taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &i, sizeof(int32_t)); } pTableListInfo->oneTableForEachGroup = groupByTbname; if (groupSort && groupByTbname) { + taosArraySort(pTableListInfo->pTableList, orderbyGroupIdComparFn); pTableListInfo->numOfOuputGroups = numOfTables; } else { pTableListInfo->numOfOuputGroups = 1; @@ -3526,6 +3524,13 @@ int32_t setGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle* p } } + // add all table entry in the hash map + size_t size = taosArrayGetSize(pTableListInfo->pTableList); + for(int32_t i = 0; i < size; ++i) { + STableKeyInfo* p = taosArrayGet(pTableListInfo->pTableList, i); + taosHashPut(pTableListInfo->map, &p->uid, sizeof(uint64_t), &i, sizeof(int32_t)); + } + return code; } @@ -3590,7 +3595,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) { STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode; int32_t code = - createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, pTableScanNode->groupSort, pHandle, + createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, /*pTableScanNode->groupSort*/true, pHandle, pTableListInfo, pTagCond, pTagIndexCond, GET_TASKID(pTaskInfo)); if (code) { pTaskInfo->code = code; @@ -3652,16 +3657,23 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } else if (QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN == type) { SBlockDistScanPhysiNode* pBlockNode = (SBlockDistScanPhysiNode*)pPhyNode; pTableListInfo->pTableList = taosArrayInit(4, sizeof(STableKeyInfo)); + pTableListInfo->numOfOuputGroups = 1; if (pBlockNode->tableType == TSDB_SUPER_TABLE) { - int32_t code = vnodeGetAllTableList(pHandle->vnode, pBlockNode->uid, pTableListInfo->pTableList); + SArray* pList = taosArrayInit(4, sizeof(STableKeyInfo)); + int32_t code = vnodeGetAllTableList(pHandle->vnode, pBlockNode->uid, pList); if (code != TSDB_CODE_SUCCESS) { pTaskInfo->code = terrno; return NULL; } + + for(int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); ++i) { + STableKeyInfo* p = taosArrayGet(pList, i); + addTableIntoTableList(pTableListInfo, p->uid, 0); + } + taosArrayDestroy(pList); } else { // Create one table group. - STableKeyInfo info = {.uid = pBlockNode->uid, .groupId = 0}; - taosArrayPush(pTableListInfo->pTableList, &info); + addTableIntoTableList(pTableListInfo, pBlockNode->uid, 0); } SQueryTableDataCond cond = {0}; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 7524a4ea1a..766d7ec18c 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1118,6 +1118,8 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU relocateColumnData(pBlock, pTableScanInfo->matchInfo.pList, pCols, true); doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo); + + pBlock->info.groupId = getTableGroupId(&pTaskInfo->tableqinfoList, binfo.uid); } tsdbReaderClose(pReader); @@ -3050,11 +3052,11 @@ static int32_t sysFilte__TableName(void* arg, SNode* pNode, SArray* result) { if (func == NULL) return -1; SMetaFltParam param = {.suid = 0, - .cid = 0, - .type = TSDB_DATA_TYPE_VARCHAR, - .val = pVal->datum.p, - .reverse = reverse, - .filterFunc = func}; + .cid = 0, + .type = TSDB_DATA_TYPE_VARCHAR, + .val = pVal->datum.p, + .reverse = reverse, + .filterFunc = func}; return -1; } @@ -3069,11 +3071,11 @@ static int32_t sysFilte__CreateTime(void* arg, SNode* pNode, SArray* result) { if (func == NULL) return -1; SMetaFltParam param = {.suid = 0, - .cid = 0, - .type = TSDB_DATA_TYPE_BIGINT, - .val = &pVal->datum.i, - .reverse = reverse, - .filterFunc = func}; + .cid = 0, + .type = TSDB_DATA_TYPE_BIGINT, + .val = &pVal->datum.i, + .reverse = reverse, + .filterFunc = func}; int32_t ret = metaFilterCreateTime(pMeta, ¶m, result); return ret; @@ -4746,9 +4748,6 @@ int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) { pInfo->queryConds = taosArrayInit(numOfTable, sizeof(SQueryTableDataCond)); for (int32_t i = 0; i < numOfTable; ++i) { - STableKeyInfo* tableKeyInfo = taosArrayGet(pInfo->tableListInfo->pTableList, i + tableStartIdx); - size_t numReaders = taosArrayGetSize(pInfo->dataReaders); - STableMergeScanSortSourceParam param = {0}; param.readerIdx = i; param.pOperator = pOperator; @@ -4959,10 +4958,6 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN goto _error; } - if (pTableScanNode->pGroupTags) { - taosArraySort(pTableListInfo->pTableList, compareTableKeyInfoByGid); - } - SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc; int32_t numOfCols = 0; @@ -5016,7 +5011,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN pOperator->cost.openCost = 0; return pOperator; - _error: +_error: pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; taosMemoryFree(pInfo); taosMemoryFree(pOperator);