feature: save work
This commit is contained in:
parent
c2a7404b42
commit
2cccfe2be4
|
@ -4921,68 +4921,118 @@ _error:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fillTableCountScanDataBlock(STableCountScanSupp* pSupp, char* dbName, char* stbName, int64_t count,
|
||||||
|
SSDataBlock* pRes) {
|
||||||
|
if (pSupp->dbNameSlotId != -1) {
|
||||||
|
ASSERT(strlen(dbName));
|
||||||
|
SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->dbNameSlotId);
|
||||||
|
char varDbName[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
strncpy(varDataVal(varDbName), dbName, strlen(dbName));
|
||||||
|
varDataSetLen(varDbName, strlen(dbName));
|
||||||
|
colDataAppend(colInfoData, 0, varDbName, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pSupp->stbNameSlotId != -1) {
|
||||||
|
ASSERT(strlen(stbName));
|
||||||
|
SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->stbNameSlotId);
|
||||||
|
char varStbName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
strncpy(varDataVal(varStbName), stbName, strlen(stbName));
|
||||||
|
varDataSetLen(varStbName, strlen(stbName));
|
||||||
|
colDataAppend(colInfoData, 0, varStbName, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pSupp->tbCountSlotId != -1) {
|
||||||
|
SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->stbNameSlotId);
|
||||||
|
colDataAppend(colInfoData, 0, (char*)&count, false);
|
||||||
|
}
|
||||||
|
pRes->info.rows = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SSDataBlock* buildSysDbTableCount(STableCountScanOperatorInfo* pInfo) {
|
||||||
|
STableCountScanSupp* pSupp = &pInfo->supp;
|
||||||
|
SSDataBlock* pRes = pInfo->pRes;
|
||||||
|
|
||||||
|
int64_t infodbTableNum;
|
||||||
|
getInfosDbMeta(NULL, &infodbTableNum);
|
||||||
|
int64_t perfdbTableNum;
|
||||||
|
getPerfDbMeta(NULL, &perfdbTableNum);
|
||||||
|
|
||||||
|
if (pSupp->groupByDbName) {
|
||||||
|
if (pInfo->currGrpIdx == 0) {
|
||||||
|
uint64_t groupId = calcGroupId(TSDB_INFORMATION_SCHEMA_DB, strlen(TSDB_INFORMATION_SCHEMA_DB));
|
||||||
|
pRes->info.groupId = groupId;
|
||||||
|
fillTableCountScanDataBlock(pSupp, TSDB_INFORMATION_SCHEMA_DB, "", infodbTableNum, pRes);
|
||||||
|
} else if (pInfo->currGrpIdx == 1) {
|
||||||
|
uint64_t groupId = calcGroupId(TSDB_PERFORMANCE_SCHEMA_DB, strlen(TSDB_PERFORMANCE_SCHEMA_DB));
|
||||||
|
pRes->info.groupId = groupId;
|
||||||
|
fillTableCountScanDataBlock(pSupp, TSDB_PERFORMANCE_SCHEMA_DB, "", perfdbTableNum, pRes);
|
||||||
|
}
|
||||||
|
pInfo->currGrpIdx++;
|
||||||
|
return (pRes->info.rows > 0) ? pRes : NULL;
|
||||||
|
} else {
|
||||||
|
if (strcmp(pSupp->dbName, TSDB_INFORMATION_SCHEMA_DB) == 0) {
|
||||||
|
fillTableCountScanDataBlock(pSupp, TSDB_INFORMATION_SCHEMA_DB, "", infodbTableNum, pRes);
|
||||||
|
} else if (strcmp(pSupp->dbName, TSDB_PERFORMANCE_SCHEMA_DB) == 0) {
|
||||||
|
fillTableCountScanDataBlock(pSupp, TSDB_PERFORMANCE_SCHEMA_DB, "", perfdbTableNum, pRes);
|
||||||
|
} else if (strlen(pSupp->dbName) == 0) {
|
||||||
|
fillTableCountScanDataBlock(pSupp, "", "", infodbTableNum + perfdbTableNum, pRes);
|
||||||
|
}
|
||||||
|
return (pRes->info.rows > 0) ? pRes : NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator) {
|
static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator) {
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
STableCountScanOperatorInfo* pInfo = pOperator->info;
|
STableCountScanOperatorInfo* pInfo = pOperator->info;
|
||||||
STableCountScanSupp* pSupp = &pInfo->supp;
|
STableCountScanSupp* pSupp = &pInfo->supp;
|
||||||
SSDataBlock* pRes = pInfo->pRes;
|
SSDataBlock* pRes = pInfo->pRes;
|
||||||
|
blockDataCleanup(pRes);
|
||||||
// compute group id must, but output is according to scancols. output group by group
|
// compute group id must, but output is according to scancols. output group by group
|
||||||
// grouptags high priority(groupid<=>grouptag), then tablename(dbname,tableName).
|
// grouptags high priority(groupid<=>grouptag), then tablename(dbname,tableName).
|
||||||
// scanCols, (grouptags cols)
|
// scanCols, (grouptags cols)
|
||||||
{
|
// mnode, query table count of information_schema and performance_schema
|
||||||
// mnode, query table count of information_schema and performance_schema
|
if (pInfo->readHandle.mnd != NULL) {
|
||||||
if (pInfo->readHandle.mnd != NULL) {
|
return buildSysDbTableCount(pInfo);
|
||||||
if (pSupp->groupByDbName) {
|
|
||||||
if (pInfo->currGrpIdx == 0) {
|
|
||||||
uint64_t groupId = calcGroupId(TSDB_INFORMATION_SCHEMA_DB, strlen(TSDB_INFORMATION_SCHEMA_DB));
|
|
||||||
size_t infodbTableNum;
|
|
||||||
getInfosDbMeta(NULL, &infodbTableNum);
|
|
||||||
pRes->info.groupId = groupId;
|
|
||||||
if (pSupp->dbNameSlotId != -1) {
|
|
||||||
SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->dbNameSlotId);
|
|
||||||
//colDataAppend(colInfoData, 0, )
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
} else if (pInfo->currGrpIdx == 1) {
|
|
||||||
uint64_t groupId = calcGroupId(TSDB_PERFORMANCE_SCHEMA_DB, strlen(TSDB_PERFORMANCE_SCHEMA_DB));
|
|
||||||
size_t perfdbTableNum;
|
|
||||||
getPerfDbMeta(NULL, &perfdbTableNum);
|
|
||||||
} else if (pInfo->currGrpIdx >= 2) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
uint64_t groupId = calcGroupId(TSDB_INFORMATION_SCHEMA_DB, strlen(TSDB_INFORMATION_SCHEMA_DB));
|
|
||||||
size_t infodbTableNum;
|
|
||||||
getInfosDbMeta(NULL, &infodbTableNum);
|
|
||||||
size_t perfdbTableNum;
|
|
||||||
getPerfDbMeta(NULL, &perfdbTableNum);
|
|
||||||
// grouptags, db name
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* db = NULL;
|
const char* db = NULL;
|
||||||
int32_t vgId = 0;
|
int32_t vgId = 0;
|
||||||
|
char dbName[TSDB_DB_FNAME_LEN] = {0};
|
||||||
|
|
||||||
{
|
{
|
||||||
// get dbname
|
// get dbname
|
||||||
vnodeGetInfo(pInfo->readHandle.vnode, &db, &vgId);
|
vnodeGetInfo(pInfo->readHandle.vnode, &db, &vgId);
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 0);
|
SColumnInfoData* pColInfoData = taosArrayGet(pInfo->pRes->pDataBlock, 0);
|
||||||
SName sn = {0};
|
SName sn = {0};
|
||||||
char varDbName[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
|
||||||
tNameFromString(&sn, db, T_NAME_ACCT | T_NAME_DB);
|
tNameFromString(&sn, db, T_NAME_ACCT | T_NAME_DB);
|
||||||
|
|
||||||
tNameGetDbName(&sn, varDataVal(varDbName));
|
tNameGetDbName(&sn, dbName);
|
||||||
varDataSetLen(varDbName, strlen(varDataVal(varDbName)));
|
|
||||||
}
|
}
|
||||||
const char* tableName = tNameGetTableName(&pInfo->tableName);
|
if (pSupp->groupByDbName) {
|
||||||
|
if (pSupp->groupByStbName) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
uint64_t groupId = calcGroupId(dbName, strlen(dbName));
|
||||||
|
pRes->info.groupId = groupId;
|
||||||
|
int64_t dbTableCount = metaGetTbNum(pInfo->readHandle.meta);
|
||||||
|
fillTableCountScanDataBlock(pSupp, dbName, "", dbTableCount, pRes);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (strlen(pSupp->dbName) != 0) {
|
||||||
|
if (strlen(pSupp->stbName) != 0) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
{
|
{
|
||||||
// grouptags only have column db_name or (no grouptags and tablename is null)
|
// grouptags only have column db_name or (no grouptags and tablename is null)
|
||||||
// if (tableName == NULL | strlen(tableName) == 0)
|
// if (tableName == NULL | strlen(tableName) == 0)
|
||||||
metaGetTbNum(pInfo->readHandle.meta);
|
metaGetTbNum(pInfo->readHandle.meta);
|
||||||
}
|
}
|
||||||
{// no grouptags and TableName is not null, return child table count
|
{// no grouptags and TableName is not null, return child table count
|
||||||
{tb_uid_t uid = metaGetTableEntryUidByName(pInfo->readHandle.meta, tableName);
|
{tb_uid_t uid = metaGetTableEntryUidByName(pInfo->readHandle.meta, pSupp->stbName);
|
||||||
SMetaStbStats stats = {0};
|
SMetaStbStats stats = {0};
|
||||||
metaGetStbStats(pInfo->readHandle.meta, uid, &stats);
|
metaGetStbStats(pInfo->readHandle.meta, uid, &stats);
|
||||||
int64_t ctbNum = stats.ctbNum;
|
int64_t ctbNum = stats.ctbNum;
|
||||||
|
|
Loading…
Reference in New Issue