From 7c3e84b7e1febb315d512ff8ef56c0cea323b777 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 3 Aug 2021 23:47:01 +0800 Subject: [PATCH] [TD-4199] enhance performance --- src/client/src/tscServer.c | 10 +++------- src/client/src/tscUtil.c | 10 ++++++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index cd79049281..8231c8b299 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2844,15 +2844,11 @@ int32_t tscGetTableMetaImpl(SSqlObj* pSql, STableMetaInfo *pTableMetaInfo, bool tNameExtractFullName(&pTableMetaInfo->name, name); size_t len = strlen(name); + if (pTableMetaInfo->tableMetaCapacity != 0) { + memset(pTableMetaInfo->pTableMeta, 0, pTableMetaInfo->tableMetaCapacity); + } taosHashGetCloneExt(tscTableMetaMap, name, len, NULL, (void **)&(pTableMetaInfo->pTableMeta), &pTableMetaInfo->tableMetaCapacity); - // TODO resize the tableMeta - //assert(size < 80 * TSDB_MAX_COLUMNS); - //if (!pSql->pBuf) { - // if (NULL == (pSql->pBuf = tcalloc(1, 80 * TSDB_MAX_COLUMNS))) { - // return TSDB_CODE_TSC_OUT_OF_MEMORY; - // } - //} STableMeta* pMeta = pTableMetaInfo->pTableMeta; if (pMeta && pMeta->id.uid > 0) { // in case of child table, here only get the diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index cf5f0b2d12..8a2fafe3e3 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -4460,17 +4460,19 @@ int32_t tscCreateTableMetaFromSTableMeta(STableMeta** ppChild, const char* name, // tableMeta exists, build child table meta according to the super table meta // the uid need to be checked in addition to the general name of the super table. if (p && p->id.uid > 0 && pChild->suid == p->id.uid) { - pChild->sversion = p->sversion; - pChild->tversion = p->tversion; - memcpy(&pChild->tableInfo, &p->tableInfo, sizeof(STableComInfo)); - int32_t totalBytes = (pChild->tableInfo.numOfColumns + pChild->tableInfo.numOfTags) * sizeof(SSchema); + int32_t totalBytes = (p->tableInfo.numOfColumns + p->tableInfo.numOfTags) * sizeof(SSchema); int32_t tableMetaSize = sizeof(STableMeta) + totalBytes; if (*tableMetaCapacity < tableMetaSize) { pChild = realloc(pChild, tableMetaSize); *tableMetaCapacity = (size_t)tableMetaSize; } + + pChild->sversion = p->sversion; + pChild->tversion = p->tversion; + memcpy(&pChild->tableInfo, &p->tableInfo, sizeof(STableComInfo)); memcpy(pChild->schema, p->schema, totalBytes); + *ppChild = pChild; tfree(p); return TSDB_CODE_SUCCESS; -- GitLab