refactor: do some internal refactor.
This commit is contained in:
parent
6fc0e1b60d
commit
4e74782799
|
@ -741,8 +741,6 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
||||||
|
|
||||||
int32_t len = (int32_t)(pStart - (char*)keyBuf);
|
int32_t len = (int32_t)(pStart - (char*)keyBuf);
|
||||||
info->groupId = calcGroupId(keyBuf, len);
|
info->groupId = calcGroupId(keyBuf, len);
|
||||||
|
|
||||||
taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &i, sizeof(int32_t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// int64_t st2 = taosGetTimestampUs();
|
// int64_t st2 = taosGetTimestampUs();
|
||||||
|
|
|
@ -3379,7 +3379,7 @@ static int32_t sortTableGroup(STableListInfo* pTableListInfo) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
taosArraySort(pTableListInfo->pTableList, orderbyGroupIdComparFn);
|
taosArraySort(pTableListInfo->pTableList, orderbyGroupIdComparFn);
|
||||||
int32_t size = getTotalTables(pTableListInfo);
|
int32_t size = taosArrayGetSize(pTableListInfo->pTableList);
|
||||||
|
|
||||||
SArray* pList = taosArrayInit(4, sizeof(int32_t));
|
SArray* pList = taosArrayInit(4, sizeof(int32_t));
|
||||||
|
|
||||||
|
@ -3403,7 +3403,6 @@ static int32_t sortTableGroup(STableListInfo* pTableListInfo) {
|
||||||
taosArrayDestroy(pList);
|
taosArrayDestroy(pList);
|
||||||
|
|
||||||
# if 0
|
# if 0
|
||||||
|
|
||||||
SArray* sortSupport = taosArrayInit(16, sizeof(uint64_t));
|
SArray* sortSupport = taosArrayInit(16, sizeof(uint64_t));
|
||||||
if (sortSupport == NULL) {
|
if (sortSupport == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
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++) {
|
for (int32_t i = 0; i < numOfTables; i++) {
|
||||||
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
info->groupId = groupByTbname? info->uid:0;
|
info->groupId = groupByTbname? info->uid:0;
|
||||||
|
|
||||||
taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &i, sizeof(int32_t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableListInfo->oneTableForEachGroup = groupByTbname;
|
pTableListInfo->oneTableForEachGroup = groupByTbname;
|
||||||
|
|
||||||
if (groupSort && groupByTbname) {
|
if (groupSort && groupByTbname) {
|
||||||
|
taosArraySort(pTableListInfo->pTableList, orderbyGroupIdComparFn);
|
||||||
pTableListInfo->numOfOuputGroups = numOfTables;
|
pTableListInfo->numOfOuputGroups = numOfTables;
|
||||||
} else {
|
} else {
|
||||||
pTableListInfo->numOfOuputGroups = 1;
|
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;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3590,7 +3595,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) {
|
||||||
STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode;
|
STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode;
|
||||||
int32_t code =
|
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));
|
pTableListInfo, pTagCond, pTagIndexCond, GET_TASKID(pTaskInfo));
|
||||||
if (code) {
|
if (code) {
|
||||||
pTaskInfo->code = code;
|
pTaskInfo->code = code;
|
||||||
|
@ -3652,16 +3657,23 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN == type) {
|
||||||
SBlockDistScanPhysiNode* pBlockNode = (SBlockDistScanPhysiNode*)pPhyNode;
|
SBlockDistScanPhysiNode* pBlockNode = (SBlockDistScanPhysiNode*)pPhyNode;
|
||||||
pTableListInfo->pTableList = taosArrayInit(4, sizeof(STableKeyInfo));
|
pTableListInfo->pTableList = taosArrayInit(4, sizeof(STableKeyInfo));
|
||||||
|
pTableListInfo->numOfOuputGroups = 1;
|
||||||
|
|
||||||
if (pBlockNode->tableType == TSDB_SUPER_TABLE) {
|
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) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
pTaskInfo->code = terrno;
|
pTaskInfo->code = terrno;
|
||||||
return NULL;
|
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.
|
} else { // Create one table group.
|
||||||
STableKeyInfo info = {.uid = pBlockNode->uid, .groupId = 0};
|
addTableIntoTableList(pTableListInfo, pBlockNode->uid, 0);
|
||||||
taosArrayPush(pTableListInfo->pTableList, &info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SQueryTableDataCond cond = {0};
|
SQueryTableDataCond cond = {0};
|
||||||
|
|
|
@ -1118,6 +1118,8 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU
|
||||||
|
|
||||||
relocateColumnData(pBlock, pTableScanInfo->matchInfo.pList, pCols, true);
|
relocateColumnData(pBlock, pTableScanInfo->matchInfo.pList, pCols, true);
|
||||||
doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo);
|
doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo);
|
||||||
|
|
||||||
|
pBlock->info.groupId = getTableGroupId(&pTaskInfo->tableqinfoList, binfo.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbReaderClose(pReader);
|
tsdbReaderClose(pReader);
|
||||||
|
@ -3050,11 +3052,11 @@ static int32_t sysFilte__TableName(void* arg, SNode* pNode, SArray* result) {
|
||||||
if (func == NULL) return -1;
|
if (func == NULL) return -1;
|
||||||
|
|
||||||
SMetaFltParam param = {.suid = 0,
|
SMetaFltParam param = {.suid = 0,
|
||||||
.cid = 0,
|
.cid = 0,
|
||||||
.type = TSDB_DATA_TYPE_VARCHAR,
|
.type = TSDB_DATA_TYPE_VARCHAR,
|
||||||
.val = pVal->datum.p,
|
.val = pVal->datum.p,
|
||||||
.reverse = reverse,
|
.reverse = reverse,
|
||||||
.filterFunc = func};
|
.filterFunc = func};
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3069,11 +3071,11 @@ static int32_t sysFilte__CreateTime(void* arg, SNode* pNode, SArray* result) {
|
||||||
if (func == NULL) return -1;
|
if (func == NULL) return -1;
|
||||||
|
|
||||||
SMetaFltParam param = {.suid = 0,
|
SMetaFltParam param = {.suid = 0,
|
||||||
.cid = 0,
|
.cid = 0,
|
||||||
.type = TSDB_DATA_TYPE_BIGINT,
|
.type = TSDB_DATA_TYPE_BIGINT,
|
||||||
.val = &pVal->datum.i,
|
.val = &pVal->datum.i,
|
||||||
.reverse = reverse,
|
.reverse = reverse,
|
||||||
.filterFunc = func};
|
.filterFunc = func};
|
||||||
|
|
||||||
int32_t ret = metaFilterCreateTime(pMeta, ¶m, result);
|
int32_t ret = metaFilterCreateTime(pMeta, ¶m, result);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -4746,9 +4748,6 @@ int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) {
|
||||||
pInfo->queryConds = taosArrayInit(numOfTable, sizeof(SQueryTableDataCond));
|
pInfo->queryConds = taosArrayInit(numOfTable, sizeof(SQueryTableDataCond));
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTable; ++i) {
|
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};
|
STableMergeScanSortSourceParam param = {0};
|
||||||
param.readerIdx = i;
|
param.readerIdx = i;
|
||||||
param.pOperator = pOperator;
|
param.pOperator = pOperator;
|
||||||
|
@ -4959,10 +4958,6 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTableScanNode->pGroupTags) {
|
|
||||||
taosArraySort(pTableListInfo->pTableList, compareTableKeyInfoByGid);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc;
|
SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc;
|
||||||
|
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
|
@ -5016,7 +5011,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
||||||
pOperator->cost.openCost = 0;
|
pOperator->cost.openCost = 0;
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
taosMemoryFree(pInfo);
|
taosMemoryFree(pInfo);
|
||||||
taosMemoryFree(pOperator);
|
taosMemoryFree(pOperator);
|
||||||
|
|
Loading…
Reference in New Issue