This commit is contained in:
Bob Liu 2023-12-28 09:45:01 +08:00
parent abed781bd3
commit a5f88a86e9
2 changed files with 9 additions and 9 deletions

View File

@ -275,7 +275,7 @@ typedef struct STableScanInfo {
int8_t scanMode; int8_t scanMode;
int8_t assignBlockUid; int8_t assignBlockUid;
uint8_t countState; // empty table count state uint8_t countState; // empty table count state
bool isOneGroup; // whether or not only one group in this scan bool isSameGroup; // whether all tables are in the same group this scan
bool hasGroupByTag; bool hasGroupByTag;
bool countOnly; bool countOnly;
bool filesetDelimited; bool filesetDelimited;

View File

@ -655,12 +655,12 @@ void setTbNameColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData,
colDataDestroy(&infoData); colDataDestroy(&infoData);
} }
static int32_t initRemainTable(STableScanInfo* pTableScanInfo, const STableKeyInfo* pList, int32_t num) { static int32_t initTableCountEnv(STableScanInfo* pTableScanInfo, const STableKeyInfo* pList, int32_t num) {
if (!pTableScanInfo->needCountEmptyTable) { if (!pTableScanInfo->needCountEmptyTable) {
pTableScanInfo->countState = TABLE_COUNT_STATE_END; pTableScanInfo->countState = TABLE_COUNT_STATE_END;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
pTableScanInfo->isOneGroup = true; pTableScanInfo->isSameGroup = true;
if (NULL == pTableScanInfo->pRemainTables) { if (NULL == pTableScanInfo->pRemainTables) {
int32_t tableNum = taosArrayGetSize(pTableScanInfo->base.pTableListInfo->pTableList); int32_t tableNum = taosArrayGetSize(pTableScanInfo->base.pTableListInfo->pTableList);
pTableScanInfo->pRemainTables = pTableScanInfo->pRemainTables =
@ -673,11 +673,11 @@ static int32_t initRemainTable(STableScanInfo* pTableScanInfo, const STableKeyIn
uint64_t groupId = 0; uint64_t groupId = 0;
for (int32_t i = 0; i < num; i++) { for (int32_t i = 0; i < num; i++) {
const STableKeyInfo* pInfo = pList + i; const STableKeyInfo* pInfo = pList + i;
if (pTableScanInfo->isOneGroup) { if (pTableScanInfo->isSameGroup) {
if (i == 0) { if (i == 0) {
groupId = pInfo->groupId; groupId = pInfo->groupId;
} else if (groupId != pInfo->groupId) { } else if (groupId != pInfo->groupId) {
pTableScanInfo->isOneGroup = false; pTableScanInfo->isSameGroup = false;
} }
} }
taosHashPut(pTableScanInfo->pRemainTables, &(pInfo->uid), sizeof(pInfo->uid), &(pInfo->groupId), sizeof(pInfo->groupId)); taosHashPut(pTableScanInfo->pRemainTables, &(pInfo->uid), sizeof(pInfo->uid), &(pInfo->groupId), sizeof(pInfo->groupId));
@ -692,8 +692,8 @@ static void markTableProcessed(STableScanInfo* pTableScanInfo, uint64_t uid) {
if (pTableScanInfo->countState > TABLE_COUNT_STATE_SCAN) { if (pTableScanInfo->countState > TABLE_COUNT_STATE_SCAN) {
return; return;
} }
// case2 only one group, uid ready // case2 if all table in same group, process only once
if (pTableScanInfo->isOneGroup) { if (pTableScanInfo->isSameGroup) {
pTableScanInfo->countState = TABLE_COUNT_STATE_END; pTableScanInfo->countState = TABLE_COUNT_STATE_END;
return; return;
} }
@ -802,7 +802,7 @@ static SSDataBlock* doGroupedTableScan(SOperatorInfo* pOperator, const STableKey
} }
if (TABLE_COUNT_STATE_NONE == pTableScanInfo->countState) { if (TABLE_COUNT_STATE_NONE == pTableScanInfo->countState) {
initRemainTable(pTableScanInfo, pList, num); initTableCountEnv(pTableScanInfo, pList, num);
} }
// do the ascending order traverse in the first place. // do the ascending order traverse in the first place.
@ -858,7 +858,7 @@ static SSDataBlock* doGroupedTableScan(SOperatorInfo* pOperator, const STableKey
if (pTableScanInfo->countState < TABLE_COUNT_STATE_END) { if (pTableScanInfo->countState < TABLE_COUNT_STATE_END) {
int32_t tb_cnt = taosHashGetSize(pTableScanInfo->pRemainTables); int32_t tb_cnt = taosHashGetSize(pTableScanInfo->pRemainTables);
if (tb_cnt) { if (tb_cnt) {
if (!pTableScanInfo->isOneGroup) { if (!pTableScanInfo->isSameGroup) {
// get first empty table uid, mark processed & rm from hash // get first empty table uid, mark processed & rm from hash
void *pIte = taosHashIterate(pTableScanInfo->pRemainTables, NULL); void *pIte = taosHashIterate(pTableScanInfo->pRemainTables, NULL);
if (pIte != NULL) { if (pIte != NULL) {