implement get cached last row function

This commit is contained in:
Hongze Cheng 2020-12-25 02:29:43 +00:00
parent 984697000e
commit 96bcd5c26f
1 changed files with 19 additions and 2 deletions

View File

@ -2183,8 +2183,25 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) {
return ret; return ret;
} }
int32_t tsdbGetCachedLastRow(STable* pTable, void** pRes) { /*
return 0; * 1. no data at all (pTable->lastKey = TSKEY_INITIAL_VAL), just return TSKEY_INITIAL_VAL
* 2. has data but not loaded, just return lastKey but not set pRes
* 3. has data and loaded, return lastKey and set pRes
*/
TSKEY tsdbGetCachedLastRow(STable* pTable, void** pRes) {
TSKEY lastKey;
TSDB_RLOCK_TABLE(pTable);
lastKey = pTable->lastKey;
if (lastKey != TSKEY_INITIAL_VAL && pTable->lastRow) {
*pRes = tdDataRowDup(pTable->lastRow);
if (*pRes == NULL) {
// TODO: handle error
}
}
TSDB_RUNLOCK_TABLE(pTable);
return lastKey;
} }
void checkCachedLastRow(STsdbQueryHandle* pQueryHandle, STableGroupInfo *groupList) { void checkCachedLastRow(STsdbQueryHandle* pQueryHandle, STableGroupInfo *groupList) {