enh: create from csv rm tbname hash

This commit is contained in:
Shungang Li 2024-09-11 17:46:53 +08:00
parent 84e675c248
commit 8af5e89d4e
1 changed files with 5 additions and 28 deletions

View File

@ -5993,7 +5993,7 @@ static int32_t isOperatorEqTbnameCond(STranslateContext* pCxt, SOperatorNode* pO
*pRet = false; *pRet = false;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
SFunctionNode* pTbnameFunc = NULL; SFunctionNode* pTbnameFunc = NULL;
SValueNode* pValueNode = NULL; SValueNode* pValueNode = NULL;
if (nodeType(pOperator->pLeft) == QUERY_NODE_FUNCTION && if (nodeType(pOperator->pLeft) == QUERY_NODE_FUNCTION &&
@ -6275,7 +6275,7 @@ static int32_t replaceToChildTableQuery(STranslateContext* pCxt, SEqCondTbNameTa
if (NULL == pMeta || TSDB_CHILD_TABLE != pMeta->tableType || pMeta->suid != pRealTable->pMeta->suid) { if (NULL == pMeta || TSDB_CHILD_TABLE != pMeta->tableType || pMeta->suid != pRealTable->pMeta->suid) {
goto _return; goto _return;
} }
pRealTable->pMeta->uid = pMeta->uid; pRealTable->pMeta->uid = pMeta->uid;
pRealTable->pMeta->vgId = pMeta->vgId; pRealTable->pMeta->vgId = pMeta->vgId;
pRealTable->pMeta->tableType = pMeta->tableType; pRealTable->pMeta->tableType = pMeta->tableType;
@ -6386,11 +6386,11 @@ static int32_t setEqualTbnameTableVgroups(STranslateContext* pCxt, SSelectStmt*
} }
qDebug("before ctbname optimize, code:%d, aTableNum:%d, nTbls:%d, stableQuery:%d", code, aTableNum, nTbls, stableQuery); qDebug("before ctbname optimize, code:%d, aTableNum:%d, nTbls:%d, stableQuery:%d", code, aTableNum, nTbls, stableQuery);
if (TSDB_CODE_SUCCESS == code && 1 == aTableNum && 1 == nTbls && stableQuery && NULL == pInfo->pRealTable->pTsmas) { if (TSDB_CODE_SUCCESS == code && 1 == aTableNum && 1 == nTbls && stableQuery && NULL == pInfo->pRealTable->pTsmas) {
code = replaceToChildTableQuery(pCxt, pInfo); code = replaceToChildTableQuery(pCxt, pInfo);
} }
return code; return code;
} }
@ -6797,7 +6797,7 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
if (pCxt->pParseCxt && pCxt->pParseCxt->setQueryFp) { if (pCxt->pParseCxt && pCxt->pParseCxt->setQueryFp) {
(*pCxt->pParseCxt->setQueryFp)(pCxt->pParseCxt->requestRid); (*pCxt->pParseCxt->setQueryFp)(pCxt->pParseCxt->requestRid);
} }
if (NULL == pSelect->pFromTable) { if (NULL == pSelect->pFromTable) {
return translateSelectWithoutFrom(pCxt, pSelect); return translateSelectWithoutFrom(pCxt, pSelect);
} else { } else {
@ -13801,7 +13801,6 @@ _OUT:
} }
typedef struct SParseFileContext { typedef struct SParseFileContext {
SHashObj* pTbNameHash;
SArray* aTagNames; SArray* aTagNames;
bool tagNameFilled; bool tagNameFilled;
STableMeta* pStbMeta; STableMeta* pStbMeta;
@ -13936,18 +13935,6 @@ static int32_t parseCsvFile(SMsgBuf* pMsgBuf, SParseContext* pParseCxt, SParseFi
code = parseOneStbRow(pMsgBuf, pParFileCxt); code = parseOneStbRow(pMsgBuf, pParFileCxt);
if (TSDB_CODE_SUCCESS == code) {
if (taosHashGet(pParFileCxt->pTbNameHash, pParFileCxt->ctbName.tname, strlen(pParFileCxt->ctbName.tname) + 1) !=
NULL) {
taosMemoryFreeClear(pParFileCxt->pTag);
code = generateSyntaxErrMsg(pMsgBuf, TSDB_CODE_PAR_TBNAME_DUPLICATED, pParFileCxt->ctbName.tname);
break;
}
code = taosHashPut(pParFileCxt->pTbNameHash, pParFileCxt->ctbName.tname, strlen(pParFileCxt->ctbName.tname) + 1,
NULL, 0);
}
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = fillVgroupInfo(pParseCxt, &pParFileCxt->ctbName, &pParFileCxt->vg); code = fillVgroupInfo(pParseCxt, &pParFileCxt->ctbName, &pParFileCxt->vg);
} }
@ -13987,7 +13974,6 @@ static void destructParseFileContext(SParseFileContext** ppParFileCxt) {
SParseFileContext* pParFileCxt = *ppParFileCxt; SParseFileContext* pParFileCxt = *ppParFileCxt;
taosHashCleanup(pParFileCxt->pTbNameHash);
taosArrayDestroy(pParFileCxt->aTagNames); taosArrayDestroy(pParFileCxt->aTagNames);
taosMemoryFreeClear(pParFileCxt->pStbMeta); taosMemoryFreeClear(pParFileCxt->pStbMeta);
taosArrayDestroy(pParFileCxt->aTagIndexs); taosArrayDestroy(pParFileCxt->aTagIndexs);
@ -14012,15 +13998,6 @@ static int32_t constructParseFileContext(SCreateSubTableFromFileClause* pStmt, S
pParFileCxt->ctbName.acctId = acctId; pParFileCxt->ctbName.acctId = acctId;
strcpy(pParFileCxt->ctbName.dbname, pStmt->useDbName); strcpy(pParFileCxt->ctbName.dbname, pStmt->useDbName);
if (NULL == pParFileCxt->pTbNameHash) {
pParFileCxt->pTbNameHash =
taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), false, HASH_NO_LOCK);
if (!pParFileCxt->pTbNameHash) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _ERR;
}
}
if (NULL == pParFileCxt->aTagNames) { if (NULL == pParFileCxt->aTagNames) {
pParFileCxt->aTagNames = taosArrayInit(8, TSDB_COL_NAME_LEN); pParFileCxt->aTagNames = taosArrayInit(8, TSDB_COL_NAME_LEN);
if (NULL == pParFileCxt->aTagNames) { if (NULL == pParFileCxt->aTagNames) {