[TD-4199]<feature> enhance performance
This commit is contained in:
parent
38d9fbc7d9
commit
93245c12f9
|
@ -340,7 +340,7 @@ STableMeta* createSuperTableMeta(STableMetaMsg* pChild);
|
||||||
uint32_t tscGetTableMetaSize(STableMeta* pTableMeta);
|
uint32_t tscGetTableMetaSize(STableMeta* pTableMeta);
|
||||||
CChildTableMeta* tscCreateChildMeta(STableMeta* pTableMeta);
|
CChildTableMeta* tscCreateChildMeta(STableMeta* pTableMeta);
|
||||||
uint32_t tscGetTableMetaMaxSize();
|
uint32_t tscGetTableMetaMaxSize();
|
||||||
int32_t tscCreateTableMetaFromSTableMeta(STableMeta* pChild, const char* name, void* buf);
|
int32_t tscCreateTableMetaFromSTableMeta(STableMeta** pChild, const char* name, size_t *tableMetaCapacity);
|
||||||
STableMeta* tscTableMetaDup(STableMeta* pTableMeta);
|
STableMeta* tscTableMetaDup(STableMeta* pTableMeta);
|
||||||
SVgroupsInfo* tscVgroupsInfoDup(SVgroupsInfo* pVgroupsInfo);
|
SVgroupsInfo* tscVgroupsInfoDup(SVgroupsInfo* pVgroupsInfo);
|
||||||
|
|
||||||
|
|
|
@ -8150,7 +8150,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
// avoid mem leak, may should update pTableMeta
|
// avoid mem leak, may should update pTableMeta
|
||||||
void* pVgroupIdList = NULL;
|
void* pVgroupIdList = NULL;
|
||||||
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
|
||||||
code = tscCreateTableMetaFromSTableMeta(pTableMeta, name, pSql->pBuf);
|
code = tscCreateTableMetaFromSTableMeta((STableMeta **)(&pTableMeta), name, &tableMetaCapacity);
|
||||||
|
|
||||||
// create the child table meta from super table failed, try load it from mnode
|
// create the child table meta from super table failed, try load it from mnode
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
@ -2857,7 +2857,7 @@ int32_t tscGetTableMetaImpl(SSqlObj* pSql, STableMetaInfo *pTableMetaInfo, bool
|
||||||
if (pMeta && pMeta->id.uid > 0) {
|
if (pMeta && pMeta->id.uid > 0) {
|
||||||
// in case of child table, here only get the
|
// in case of child table, here only get the
|
||||||
if (pMeta->tableType == TSDB_CHILD_TABLE) {
|
if (pMeta->tableType == TSDB_CHILD_TABLE) {
|
||||||
int32_t code = tscCreateTableMetaFromSTableMeta(pTableMetaInfo->pTableMeta, name, pSql->pBuf);
|
int32_t code = tscCreateTableMetaFromSTableMeta(&pTableMetaInfo->pTableMeta, name, &pTableMetaInfo->tableMetaCapacity);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return getTableMetaFromMnode(pSql, pTableMetaInfo, autocreate);
|
return getTableMetaFromMnode(pSql, pTableMetaInfo, autocreate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4448,11 +4448,13 @@ CChildTableMeta* tscCreateChildMeta(STableMeta* pTableMeta) {
|
||||||
return cMeta;
|
return cMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscCreateTableMetaFromSTableMeta(STableMeta* pChild, const char* name, void* buf) {
|
int32_t tscCreateTableMetaFromSTableMeta(STableMeta** ppChild, const char* name, size_t *tableMetaCapacity) {
|
||||||
assert(pChild != NULL);
|
assert(*ppChild != NULL);
|
||||||
|
|
||||||
STableMeta* p = NULL;
|
STableMeta* p = NULL;
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
|
STableMeta* pChild = *ppChild;
|
||||||
|
|
||||||
taosHashGetCloneExt(tscTableMetaMap, pChild->sTableName, strnlen(pChild->sTableName, TSDB_TABLE_FNAME_LEN), NULL, (void **)&p, &sz);
|
taosHashGetCloneExt(tscTableMetaMap, pChild->sTableName, strnlen(pChild->sTableName, TSDB_TABLE_FNAME_LEN), NULL, (void **)&p, &sz);
|
||||||
|
|
||||||
// tableMeta exists, build child table meta according to the super table meta
|
// tableMeta exists, build child table meta according to the super table meta
|
||||||
|
@ -4462,9 +4464,14 @@ int32_t tscCreateTableMetaFromSTableMeta(STableMeta* pChild, const char* name, v
|
||||||
pChild->tversion = p->tversion;
|
pChild->tversion = p->tversion;
|
||||||
|
|
||||||
memcpy(&pChild->tableInfo, &p->tableInfo, sizeof(STableComInfo));
|
memcpy(&pChild->tableInfo, &p->tableInfo, sizeof(STableComInfo));
|
||||||
int32_t total = pChild->tableInfo.numOfColumns + pChild->tableInfo.numOfTags;
|
int32_t totalBytes = (pChild->tableInfo.numOfColumns + pChild->tableInfo.numOfTags) * sizeof(SSchema);
|
||||||
|
int32_t tableMetaSize = sizeof(STableMeta) + totalBytes;
|
||||||
memcpy(pChild->schema, p->schema, sizeof(SSchema) *total);
|
if (*tableMetaCapacity < tableMetaSize) {
|
||||||
|
pChild = realloc(pChild, tableMetaSize);
|
||||||
|
*tableMetaCapacity = (size_t)tableMetaSize;
|
||||||
|
}
|
||||||
|
memcpy(pChild->schema, p->schema, totalBytes);
|
||||||
|
*ppChild = pChild;
|
||||||
tfree(p);
|
tfree(p);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
} else { // super table has been removed, current tableMeta is also expired. remove it here
|
} else { // super table has been removed, current tableMeta is also expired. remove it here
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "tulog.h"
|
#include "tulog.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
|
|
||||||
#define EXT_SIZE 512
|
#define EXT_SIZE 1024
|
||||||
|
|
||||||
#define HASH_NEED_RESIZE(_h) ((_h)->size >= (_h)->capacity * HASH_DEFAULT_LOAD_FACTOR)
|
#define HASH_NEED_RESIZE(_h) ((_h)->size >= (_h)->capacity * HASH_DEFAULT_LOAD_FACTOR)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue