tsdbCache: remove deprecated & bugged get last row implementation
This commit is contained in:
parent
0d77d034e5
commit
caf6e8439f
|
@ -957,33 +957,6 @@ _err:
|
||||||
return code;
|
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 tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHandle **handle) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
char key[32] = {0};
|
char key[32] = {0};
|
||||||
|
|
|
@ -117,6 +117,7 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t
|
||||||
|
|
||||||
SLastrowReader* pr = pReader;
|
SLastrowReader* pr = pReader;
|
||||||
|
|
||||||
|
SLRUCache* lruCache = pr->pVnode->pTsdb->lruCache;
|
||||||
LRUHandle* h = NULL;
|
LRUHandle* h = NULL;
|
||||||
STSRow* pRow = NULL;
|
STSRow* pRow = NULL;
|
||||||
size_t numOfTables = taosArrayGetSize(pr->pTableList);
|
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) {
|
for (int32_t i = 0; i < numOfTables; ++i) {
|
||||||
STableKeyInfo* pKeyInfo = taosArrayGet(pr->pTableList, 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(lruCache, pKeyInfo->uid, pr->pVnode->pTsdb, &h);
|
||||||
int32_t code = tsdbCacheGetLastrowH(pr->pVnode->pTsdb->lruCache, pKeyInfo->uid, pr->pVnode->pTsdb, &h);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRow = (STSRow*)taosLRUCacheValue(pr->pVnode->pTsdb->lruCache, h);
|
pRow = (STSRow*)taosLRUCacheValue(lruCache, h);
|
||||||
if (pRow->ts > lastKey) {
|
if (pRow->ts > lastKey) {
|
||||||
// Set result row into the same rowIndex repeatly, so we need to check if the internal result row has already
|
// Set result row into the same rowIndex repeatly, so we need to check if the internal result row has already
|
||||||
// appended or not.
|
// appended or not.
|
||||||
|
@ -151,14 +151,13 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t
|
||||||
lastKey = pRow->ts;
|
lastKey = pRow->ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbCacheRelease(pr->pVnode->pTsdb->lruCache, h);
|
tsdbCacheRelease(lruCache, h);
|
||||||
}
|
}
|
||||||
} else if (pr->type == LASTROW_RETRIEVE_TYPE_ALL) {
|
} else if (pr->type == LASTROW_RETRIEVE_TYPE_ALL) {
|
||||||
for (int32_t i = pr->tableIndex; i < numOfTables; ++i) {
|
for (int32_t i = pr->tableIndex; i < numOfTables; ++i) {
|
||||||
STableKeyInfo* pKeyInfo = taosArrayGet(pr->pTableList, 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(lruCache, pKeyInfo->uid, pr->pVnode->pTsdb, &h);
|
||||||
int32_t code = tsdbCacheGetLastrowH(pr->pVnode->pTsdb->lruCache, pKeyInfo->uid, pr->pVnode->pTsdb, &h);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -168,10 +167,10 @@ int32_t tsdbRetrieveLastRow(void* pReader, SSDataBlock* pResBlock, const int32_t
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRow = (STSRow*)taosLRUCacheValue(pr->pVnode->pTsdb->lruCache, h);
|
pRow = (STSRow*)taosLRUCacheValue(lruCache, h);
|
||||||
saveOneRow(pRow, pResBlock, pr, slotIds);
|
saveOneRow(pRow, pResBlock, pr, slotIds);
|
||||||
|
|
||||||
tsdbCacheRelease(pr->pVnode->pTsdb->lruCache, h);
|
tsdbCacheRelease(lruCache, h);
|
||||||
|
|
||||||
pr->tableIndex += 1;
|
pr->tableIndex += 1;
|
||||||
if (pResBlock->info.rows >= pResBlock->info.capacity) {
|
if (pResBlock->info.rows >= pResBlock->info.capacity) {
|
||||||
|
|
Loading…
Reference in New Issue