enh(query): opt filter check.

This commit is contained in:
Haojun Liao 2023-01-10 19:31:30 +08:00
parent 94c416eb30
commit 2d73a50469
1 changed files with 23 additions and 9 deletions

View File

@ -549,21 +549,35 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
tdListAppend(&p->list, pKey); tdListAppend(&p->list, pKey);
} else { } else {
// check if it exists or not // check if it exists or not
SListIter iter = {0}; size_t size = listNEles(&(*pEntry)->list);
tdListInitIter(&(*pEntry)->list, &iter, TD_LIST_FORWARD); if (size == 0) {
tdListAppend(&(*pEntry)->list, pKey);
SListNode* pNode = NULL; } else if (size == 1) {
while ((pNode = tdListNext(&iter)) != NULL) { SListNode* pNode = listHead(&(*pEntry)->list);
uint64_t* p = (uint64_t*) pNode->data; uint64_t* p = (uint64_t*) pNode->data;
// key already exists in cache, quit
if (p[1] == ((uint64_t*)pKey)[1] && p[2] == ((uint64_t*)pKey)[2]) { if (p[1] == ((uint64_t*)pKey)[1] && p[2] == ((uint64_t*)pKey)[2]) {
taosThreadMutexUnlock(pLock); taosThreadMutexUnlock(pLock);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} else { // not equal, append it
tdListAppend(&(*pEntry)->list, pKey);
} }
} } else { // more than one element
SListIter iter = {0};
tdListInitIter(&(*pEntry)->list, &iter, TD_LIST_FORWARD);
tdListAppend(&(*pEntry)->list, pKey); SListNode* pNode = NULL;
while ((pNode = tdListNext(&iter)) != NULL) {
uint64_t* p = (uint64_t*)pNode->data;
// key already exists in cache, quit
if (p[1] == ((uint64_t*)pKey)[1] && p[2] == ((uint64_t*)pKey)[2]) {
taosThreadMutexUnlock(pLock);
return TSDB_CODE_SUCCESS;
}
}
tdListAppend(&(*pEntry)->list, pKey);
}
} }
// add to cache. // add to cache.