fix: add seperate group for normal table when group by db_name/stbable_name
This commit is contained in:
parent
920eac302e
commit
58c75dde6f
|
@ -107,23 +107,23 @@ int32_t metaReadNext(SMetaReader *pReader);
|
||||||
const void *metaGetTableTagVal(void *tag, int16_t type, STagVal *tagVal);
|
const void *metaGetTableTagVal(void *tag, int16_t type, STagVal *tagVal);
|
||||||
int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName);
|
int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName);
|
||||||
|
|
||||||
int metaGetTableSzNameByUid(void *meta, uint64_t uid, char *tbName);
|
int metaGetTableSzNameByUid(void *meta, uint64_t uid, char *tbName);
|
||||||
int metaGetTableUidByName(void *meta, char *tbName, uint64_t *uid);
|
int metaGetTableUidByName(void *meta, char *tbName, uint64_t *uid);
|
||||||
int metaGetTableTypeByName(void *meta, char *tbName, ETableType *tbType);
|
int metaGetTableTypeByName(void *meta, char *tbName, ETableType *tbType);
|
||||||
bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid);
|
bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid);
|
||||||
int32_t metaGetCachedTableUidList(SMeta *pMeta, tb_uid_t suid, const uint8_t *key, int32_t keyLen, SArray *pList,
|
int32_t metaGetCachedTableUidList(SMeta *pMeta, tb_uid_t suid, const uint8_t *key, int32_t keyLen, SArray *pList,
|
||||||
bool *acquired);
|
bool *acquired);
|
||||||
int32_t metaUidFilterCachePut(SMeta *pMeta, uint64_t suid, const void *pKey, int32_t keyLen, void *pPayload,
|
int32_t metaUidFilterCachePut(SMeta *pMeta, uint64_t suid, const void *pKey, int32_t keyLen, void *pPayload,
|
||||||
int32_t payloadLen, double selectivityRatio);
|
int32_t payloadLen, double selectivityRatio);
|
||||||
int32_t metaUidCacheClear(SMeta *pMeta, uint64_t suid);
|
int32_t metaUidCacheClear(SMeta *pMeta, uint64_t suid);
|
||||||
tb_uid_t metaGetTableEntryUidByName(SMeta* pMeta, const char* name);
|
tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name);
|
||||||
int64_t metaGetTbNum(SMeta* pMeta);
|
int64_t metaGetTbNum(SMeta *pMeta);
|
||||||
|
int64_t metaGetNtbNum(SMeta *pMeta);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t uid;
|
int64_t uid;
|
||||||
int64_t ctbNum;
|
int64_t ctbNum;
|
||||||
} SMetaStbStats;
|
} SMetaStbStats;
|
||||||
int32_t metaGetStbStats(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo);
|
int32_t metaGetStbStats(SMeta *pMeta, int64_t uid, SMetaStbStats *pInfo);
|
||||||
|
|
||||||
typedef struct SMetaFltParam {
|
typedef struct SMetaFltParam {
|
||||||
tb_uid_t suid;
|
tb_uid_t suid;
|
||||||
|
|
|
@ -756,6 +756,10 @@ int64_t metaGetTimeSeriesNum(SMeta *pMeta) {
|
||||||
return pMeta->pVnode->config.vndStats.numOfTimeSeries + pMeta->pVnode->config.vndStats.numOfNTimeSeries;
|
return pMeta->pVnode->config.vndStats.numOfTimeSeries + pMeta->pVnode->config.vndStats.numOfNTimeSeries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t metaGetNtbNum(SMeta *pMeta) {
|
||||||
|
return pMeta->pVnode->config.vndStats.numOfNTables;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SMeta *pMeta;
|
SMeta *pMeta;
|
||||||
TBC *pCur;
|
TBC *pCur;
|
||||||
|
|
|
@ -3050,7 +3050,7 @@ _error:
|
||||||
void fillTableCountScanDataBlock(STableCountScanSupp* pSupp, char* dbName, char* stbName, int64_t count,
|
void fillTableCountScanDataBlock(STableCountScanSupp* pSupp, char* dbName, char* stbName, int64_t count,
|
||||||
SSDataBlock* pRes) {
|
SSDataBlock* pRes) {
|
||||||
if (pSupp->dbNameSlotId != -1) {
|
if (pSupp->dbNameSlotId != -1) {
|
||||||
ASSERT(strlen(dbName));
|
ASSERT(strlen(pSupp->dbName));
|
||||||
SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->dbNameSlotId);
|
SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->dbNameSlotId);
|
||||||
char varDbName[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char varDbName[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
strncpy(varDataVal(varDbName), dbName, strlen(dbName));
|
strncpy(varDataVal(varDbName), dbName, strlen(dbName));
|
||||||
|
@ -3059,12 +3059,15 @@ void fillTableCountScanDataBlock(STableCountScanSupp* pSupp, char* dbName, char*
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSupp->stbNameSlotId != -1) {
|
if (pSupp->stbNameSlotId != -1) {
|
||||||
ASSERT(strlen(stbName));
|
|
||||||
SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->stbNameSlotId);
|
SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->stbNameSlotId);
|
||||||
char varStbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
if (strlen(stbName) != 0) {
|
||||||
strncpy(varDataVal(varStbName), stbName, strlen(stbName));
|
char varStbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
varDataSetLen(varStbName, strlen(stbName));
|
strncpy(varDataVal(varStbName), stbName, strlen(stbName));
|
||||||
colDataAppend(colInfoData, 0, varStbName, false);
|
varDataSetLen(varStbName, strlen(stbName));
|
||||||
|
colDataAppend(colInfoData, 0, varStbName, false);
|
||||||
|
} else {
|
||||||
|
colDataAppendNULL(colInfoData, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSupp->tbCountSlotId != -1) {
|
if (pSupp->tbCountSlotId != -1) {
|
||||||
|
@ -3084,10 +3087,6 @@ static SSDataBlock* buildSysDbTableCount(SOperatorInfo* pOperator, STableCountSc
|
||||||
getPerfDbMeta(NULL, &perfdbTableNum);
|
getPerfDbMeta(NULL, &perfdbTableNum);
|
||||||
|
|
||||||
if (pSupp->groupByDbName) {
|
if (pSupp->groupByDbName) {
|
||||||
if (pSupp->groupByStbName) {
|
|
||||||
setOperatorCompleted(pOperator);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (pInfo->currGrpIdx == 0) {
|
if (pInfo->currGrpIdx == 0) {
|
||||||
uint64_t groupId = calcGroupId(TSDB_INFORMATION_SCHEMA_DB, strlen(TSDB_INFORMATION_SCHEMA_DB));
|
uint64_t groupId = calcGroupId(TSDB_INFORMATION_SCHEMA_DB, strlen(TSDB_INFORMATION_SCHEMA_DB));
|
||||||
pRes->info.id.groupId = groupId;
|
pRes->info.id.groupId = groupId;
|
||||||
|
@ -3121,10 +3120,7 @@ static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator) {
|
||||||
STableCountScanSupp* pSupp = &pInfo->supp;
|
STableCountScanSupp* pSupp = &pInfo->supp;
|
||||||
SSDataBlock* pRes = pInfo->pRes;
|
SSDataBlock* pRes = pInfo->pRes;
|
||||||
blockDataCleanup(pRes);
|
blockDataCleanup(pRes);
|
||||||
// compute group id must, but output is according to scancols. output group by group
|
|
||||||
// grouptags high priority(groupid<=>grouptag), then tablename(dbname,tableName).
|
|
||||||
// scanCols, (grouptags cols)
|
|
||||||
// mnode, query table count of information_schema and performance_schema
|
|
||||||
if (pOperator->status == OP_EXEC_DONE) {
|
if (pOperator->status == OP_EXEC_DONE) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -3145,7 +3141,6 @@ static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
if (pSupp->groupByDbName) {
|
if (pSupp->groupByDbName) {
|
||||||
if (pSupp->groupByStbName) {
|
if (pSupp->groupByStbName) {
|
||||||
// group by db_name and stable_name
|
|
||||||
if (pInfo->stbUidList == NULL) {
|
if (pInfo->stbUidList == NULL) {
|
||||||
pInfo->stbUidList = taosArrayInit(16, sizeof(tb_uid_t));
|
pInfo->stbUidList = taosArrayInit(16, sizeof(tb_uid_t));
|
||||||
if (vnodeGetStbIdList(pInfo->readHandle.vnode, 0, pInfo->stbUidList) < 0) {
|
if (vnodeGetStbIdList(pInfo->readHandle.vnode, 0, pInfo->stbUidList) < 0) {
|
||||||
|
@ -3169,13 +3164,21 @@ static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
fillTableCountScanDataBlock(pSupp, dbName, stbName, ctbNum, pRes);
|
fillTableCountScanDataBlock(pSupp, dbName, stbName, ctbNum, pRes);
|
||||||
|
|
||||||
|
pInfo->currGrpIdx++;
|
||||||
|
} else if (pInfo->currGrpIdx == taosArrayGetSize(pInfo->stbUidList)) {
|
||||||
|
char fullStbName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
snprintf(fullStbName, TSDB_TABLE_FNAME_LEN, "%s.%s", dbName, "");
|
||||||
|
uint64_t groupId = calcGroupId(fullStbName, strlen(fullStbName));
|
||||||
|
pRes->info.id.groupId = groupId;
|
||||||
|
int64_t ntbNum = metaGetNtbNum(pInfo->readHandle.meta);
|
||||||
|
fillTableCountScanDataBlock(pSupp, dbName, "", ntbNum, pRes);
|
||||||
|
|
||||||
pInfo->currGrpIdx++;
|
pInfo->currGrpIdx++;
|
||||||
} else {
|
} else {
|
||||||
setOperatorCompleted(pOperator);
|
setOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// group by only db_name
|
|
||||||
uint64_t groupId = calcGroupId(dbName, strlen(dbName));
|
uint64_t groupId = calcGroupId(dbName, strlen(dbName));
|
||||||
pRes->info.id.groupId = groupId;
|
pRes->info.id.groupId = groupId;
|
||||||
int64_t dbTableCount = metaGetTbNum(pInfo->readHandle.meta);
|
int64_t dbTableCount = metaGetTbNum(pInfo->readHandle.meta);
|
||||||
|
|
Loading…
Reference in New Issue