From caf6e8439f4f20e4d7c1ccb09ad28a3153f87aac Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Thu, 30 Jun 2022 20:44:52 +0800 Subject: [PATCH] tsdbCache: remove deprecated & bugged get last row implementation --- source/dnode/vnode/src/tsdb/tsdbCache.c | 27 --------------------- source/dnode/vnode/src/tsdb/tsdbCacheRead.c | 15 ++++++------ 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index b51a010df7..8372c1870f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -957,33 +957,6 @@ _err: return code; } -int32_t tsdbCacheGetLastrow(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) { - int32_t code = 0; - char key[32] = {0}; - int keyLen = 0; - - getTableCacheKey(uid, "lr", key, &keyLen); - LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen); - if (h) { - *ppRow = (STSRow *)taosLRUCacheValue(pCache, h); - } else { - STSRow *pRow = NULL; - code = mergeLastRow(uid, pTsdb, &pRow); - // if table's empty or error, return code of -1 - if (code < 0 || pRow == NULL) { - return -1; - } - - tsdbCacheInsertLastrow(pCache, uid, pRow); - LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen); - *ppRow = (STSRow *)taosLRUCacheValue(pCache, h); - } - - // taosLRUCacheRelease(pCache, h, true); - - return code; -} - int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHandle **handle) { int32_t code = 0; char key[32] = {0}; diff --git a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c index e00c165f99..98e4bf141b 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c @@ -117,6 +117,7 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t SLastrowReader* pr = pReader; + SLRUCache* lruCache = pr->pVnode->pTsdb->lruCache; LRUHandle* h = NULL; STSRow* pRow = NULL; size_t numOfTables = taosArrayGetSize(pr->pTableList); @@ -128,8 +129,7 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t for (int32_t i = 0; i < numOfTables; ++i) { STableKeyInfo* pKeyInfo = taosArrayGet(pr->pTableList, i); - /* int32_t code = tsdbCacheGetLastrow(pr->pVnode->pTsdb->lruCache, pKeyInfo->uid, pr->pVnode->pTsdb, &pRow); */ - int32_t code = tsdbCacheGetLastrowH(pr->pVnode->pTsdb->lruCache, pKeyInfo->uid, pr->pVnode->pTsdb, &h); + int32_t code = tsdbCacheGetLastrowH(lruCache, pKeyInfo->uid, pr->pVnode->pTsdb, &h); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -138,7 +138,7 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t continue; } - pRow = (STSRow*)taosLRUCacheValue(pr->pVnode->pTsdb->lruCache, h); + pRow = (STSRow*)taosLRUCacheValue(lruCache, h); if (pRow->ts > lastKey) { // Set result row into the same rowIndex repeatly, so we need to check if the internal result row has already // appended or not. @@ -151,14 +151,13 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t lastKey = pRow->ts; } - tsdbCacheRelease(pr->pVnode->pTsdb->lruCache, h); + tsdbCacheRelease(lruCache, h); } } else if (pr->type == LASTROW_RETRIEVE_TYPE_ALL) { for (int32_t i = pr->tableIndex; i < numOfTables; ++i) { STableKeyInfo* pKeyInfo = taosArrayGet(pr->pTableList, i); - /* int32_t code = tsdbCacheGetLastrow(pr->pVnode->pTsdb->lruCache, pKeyInfo->uid, pr->pVnode->pTsdb, &pRow); */ - int32_t code = tsdbCacheGetLastrowH(pr->pVnode->pTsdb->lruCache, pKeyInfo->uid, pr->pVnode->pTsdb, &h); + int32_t code = tsdbCacheGetLastrowH(lruCache, pKeyInfo->uid, pr->pVnode->pTsdb, &h); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -168,10 +167,10 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t continue; } - pRow = (STSRow*)taosLRUCacheValue(pr->pVnode->pTsdb->lruCache, h); + pRow = (STSRow*)taosLRUCacheValue(lruCache, h); saveOneRow(pRow, pResBlock, pr, slotIds); - tsdbCacheRelease(pr->pVnode->pTsdb->lruCache, h); + tsdbCacheRelease(lruCache, h); pr->tableIndex += 1; if (pResBlock->info.rows >= pResBlock->info.capacity) { -- GitLab