chore: more code

This commit is contained in:
kailixu 2023-07-11 12:37:01 +08:00
parent 14b438ec64
commit d5435926c2
2 changed files with 8 additions and 10 deletions

View File

@ -68,7 +68,7 @@ struct SMetaCache {
} STbGroupResCache; } STbGroupResCache;
struct STbFilterCache { struct STbFilterCache {
SHashObj* pTkLogStb; SHashObj* pStb;
} STbFilterCache; } STbFilterCache;
}; };
@ -172,9 +172,8 @@ int32_t metaCacheOpen(SMeta* pMeta) {
taosHashSetFreeFp(pCache->STbGroupResCache.pTableEntry, freeCacheEntryFp); taosHashSetFreeFp(pCache->STbGroupResCache.pTableEntry, freeCacheEntryFp);
taosThreadMutexInit(&pCache->STbGroupResCache.lock, NULL); taosThreadMutexInit(&pCache->STbGroupResCache.lock, NULL);
pCache->STbFilterCache.pTkLogStb = pCache->STbFilterCache.pStb = taosHashInit(0, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
taosHashInit(0, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); if (pCache->STbFilterCache.pStb == NULL) {
if (pCache->STbFilterCache.pTkLogStb == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
goto _err2; goto _err2;
} }
@ -204,7 +203,7 @@ void metaCacheClose(SMeta* pMeta) {
taosThreadMutexDestroy(&pMeta->pCache->STbGroupResCache.lock); taosThreadMutexDestroy(&pMeta->pCache->STbGroupResCache.lock);
taosHashCleanup(pMeta->pCache->STbGroupResCache.pTableEntry); taosHashCleanup(pMeta->pCache->STbGroupResCache.pTableEntry);
taosHashCleanup(pMeta->pCache->STbFilterCache.pTkLogStb); taosHashCleanup(pMeta->pCache->STbFilterCache.pStb);
taosMemoryFree(pMeta->pCache); taosMemoryFree(pMeta->pCache);
pMeta->pCache = NULL; pMeta->pCache = NULL;
@ -897,7 +896,7 @@ int32_t metaTbGroupCacheClear(SMeta* pMeta, uint64_t suid) {
bool metaTbInFilterCache(void* pVnode, tb_uid_t suid, int8_t type) { bool metaTbInFilterCache(void* pVnode, tb_uid_t suid, int8_t type) {
SMeta* pMeta = ((SVnode*)pVnode)->pMeta; SMeta* pMeta = ((SVnode*)pVnode)->pMeta;
if (type == 0 && taosHashGet(pMeta->pCache->STbFilterCache.pTkLogStb, &suid, sizeof(suid))) { if (type == 0 && taosHashGet(pMeta->pCache->STbFilterCache.pStb, &suid, sizeof(suid))) {
return true; return true;
} }
@ -908,7 +907,7 @@ int32_t metaPutTbToFilterCache(void* pVnode, tb_uid_t suid, int8_t type) {
SMeta* pMeta = ((SVnode*)pVnode)->pMeta; SMeta* pMeta = ((SVnode*)pVnode)->pMeta;
if (type == 0) { if (type == 0) {
return taosHashPut(pMeta->pCache->STbFilterCache.pTkLogStb, &suid, sizeof(suid), NULL, 0); return taosHashPut(pMeta->pCache->STbFilterCache.pStb, &suid, sizeof(suid), NULL, 0);
} }
return 0; return 0;
@ -917,7 +916,7 @@ int32_t metaPutTbToFilterCache(void* pVnode, tb_uid_t suid, int8_t type) {
int32_t metaSizeOfTbFilterCache(void* pVnode, int8_t type) { int32_t metaSizeOfTbFilterCache(void* pVnode, int8_t type) {
SMeta* pMeta = ((SVnode*)pVnode)->pMeta; SMeta* pMeta = ((SVnode*)pVnode)->pMeta;
if (type == 0) { if (type == 0) {
return taosHashGetSize(pMeta->pCache->STbFilterCache.pTkLogStb); return taosHashGetSize(pMeta->pCache->STbFilterCache.pStb);
} }
return 0; return 0;
} }

View File

@ -580,8 +580,7 @@ static const char *tkLogStb[TK_LOG_STB_NUM] = {"cluster_info",
// exclude stbs of taoskeeper log // exclude stbs of taoskeeper log
static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode) { static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode) {
char *dbName = strchr(pVnode->config.dbname, '.'); char *dbName = strchr(pVnode->config.dbname, '.');
++dbName; if (!dbName || 0 != strncmp(++dbName, "log", TSDB_DB_NAME_LEN)) {
if (!dbName || 0 != strncmp(dbName, "log", TSDB_DB_NAME_LEN)) {
return 0; return 0;
} }
int32_t tbSize = metaSizeOfTbFilterCache(pVnode, 0); int32_t tbSize = metaSizeOfTbFilterCache(pVnode, 0);