operator/cache-scan: pass col list down to tsdb cache
This commit is contained in:
parent
dee2ca3476
commit
76edc16ce1
|
@ -194,7 +194,7 @@ void *tsdbGetIvtIdx(SMeta *pMeta);
|
||||||
uint64_t getReaderMaxVersion(STsdbReader *pReader);
|
uint64_t getReaderMaxVersion(STsdbReader *pReader);
|
||||||
|
|
||||||
int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||||
uint64_t suid, void **pReader, const char *idstr);
|
SArray *pCidList, uint64_t suid, void **pReader, const char *idstr);
|
||||||
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids);
|
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids);
|
||||||
void *tsdbCacherowsReaderClose(void *pReader);
|
void *tsdbCacherowsReaderClose(void *pReader);
|
||||||
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
||||||
|
|
|
@ -787,6 +787,7 @@ typedef struct SCacheRowsReader {
|
||||||
uint64_t suid;
|
uint64_t suid;
|
||||||
char **transferBuf; // todo remove it soon
|
char **transferBuf; // todo remove it soon
|
||||||
int32_t numOfCols;
|
int32_t numOfCols;
|
||||||
|
SArray *pCidList;
|
||||||
int32_t type;
|
int32_t type;
|
||||||
int32_t tableIndex; // currently returned result tables
|
int32_t tableIndex; // currently returned result tables
|
||||||
STableKeyInfo *pTableList; // table id list
|
STableKeyInfo *pTableList; // table id list
|
||||||
|
|
|
@ -283,6 +283,14 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tsdbCacheGetLast(STsdb *pTsdb, tb_uid_t uid, SArray **ppLastArray, SCacheRowsReader *pr) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
SArray *pCidList = pr->pCidList;
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tsdbOpenCache(STsdb *pTsdb) {
|
int32_t tsdbOpenCache(STsdb *pTsdb) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SLRUCache *pCache = NULL;
|
SLRUCache *pCache = NULL;
|
||||||
|
|
|
@ -143,7 +143,7 @@ static int32_t setTableSchema(SCacheRowsReader* p, uint64_t suid, const char* id
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||||
uint64_t suid, void** pReader, const char* idstr) {
|
SArray* pCidList, uint64_t suid, void** pReader, const char* idstr) {
|
||||||
*pReader = NULL;
|
*pReader = NULL;
|
||||||
SCacheRowsReader* p = taosMemoryCalloc(1, sizeof(SCacheRowsReader));
|
SCacheRowsReader* p = taosMemoryCalloc(1, sizeof(SCacheRowsReader));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
|
@ -155,6 +155,7 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList,
|
||||||
p->pTsdb = p->pVnode->pTsdb;
|
p->pTsdb = p->pVnode->pTsdb;
|
||||||
p->verRange = (SVersionRange){.minVer = 0, .maxVer = UINT64_MAX};
|
p->verRange = (SVersionRange){.minVer = 0, .maxVer = UINT64_MAX};
|
||||||
p->numOfCols = numOfCols;
|
p->numOfCols = numOfCols;
|
||||||
|
p->pCidList = pCidList;
|
||||||
p->suid = suid;
|
p->suid = suid;
|
||||||
|
|
||||||
if (numOfTables == 0) {
|
if (numOfTables == 0) {
|
||||||
|
|
|
@ -36,6 +36,7 @@ typedef struct SCacheRowsScanInfo {
|
||||||
int32_t currentGroupIndex;
|
int32_t currentGroupIndex;
|
||||||
SSDataBlock* pBufferredRes;
|
SSDataBlock* pBufferredRes;
|
||||||
SArray* pUidList;
|
SArray* pUidList;
|
||||||
|
SArray* pCidList;
|
||||||
int32_t indexOfBufferedRes;
|
int32_t indexOfBufferedRes;
|
||||||
STableListInfo* pTableList;
|
STableListInfo* pTableList;
|
||||||
} SCacheRowsScanInfo;
|
} SCacheRowsScanInfo;
|
||||||
|
@ -71,6 +72,13 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SArray* pCidList = taosArrayInit(numOfCols, sizeof(int16_t));
|
||||||
|
for (int i = 0; i < TARRAY_SIZE(pInfo->matchInfo.pList); ++i) {
|
||||||
|
SColMatchItem* pColInfo = taosArrayGet(pInfo->matchInfo.pList, i);
|
||||||
|
taosArrayPush(pCidList, &pColInfo->colId);
|
||||||
|
}
|
||||||
|
pInfo->pCidList = pCidList;
|
||||||
|
|
||||||
removeRedundantTsCol(pScanNode, &pInfo->matchInfo);
|
removeRedundantTsCol(pScanNode, &pInfo->matchInfo);
|
||||||
|
|
||||||
code = extractCacheScanSlotId(pInfo->matchInfo.pList, pTaskInfo, &pInfo->pSlotIds);
|
code = extractCacheScanSlotId(pInfo->matchInfo.pList, pTaskInfo, &pInfo->pSlotIds);
|
||||||
|
@ -91,7 +99,8 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
||||||
|
|
||||||
uint64_t suid = tableListGetSuid(pTableListInfo);
|
uint64_t suid = tableListGetSuid(pTableListInfo);
|
||||||
code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, totalTables,
|
code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, totalTables,
|
||||||
taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader, pTaskInfo->id.str);
|
taosArrayGetSize(pInfo->matchInfo.pList), pCidList, suid, &pInfo->pLastrowReader,
|
||||||
|
pTaskInfo->id.str);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +123,8 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
||||||
p->pCtx = createSqlFunctionCtx(p->pExprInfo, p->numOfExprs, &p->rowEntryInfoOffset);
|
p->pCtx = createSqlFunctionCtx(p->pExprInfo, p->numOfExprs, &p->rowEntryInfoOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
setOperatorInfo(pOperator, "CachedRowScanOperator", QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
setOperatorInfo(pOperator, "CachedRowScanOperator", QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN, false, OP_NOT_OPENED,
|
||||||
|
pInfo, pTaskInfo);
|
||||||
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
||||||
|
|
||||||
pOperator->fpSet =
|
pOperator->fpSet =
|
||||||
|
@ -225,8 +235,8 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, num,
|
code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, num,
|
||||||
taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader,
|
taosArrayGetSize(pInfo->matchInfo.pList), pInfo->pCidList, suid,
|
||||||
pTaskInfo->id.str);
|
&pInfo->pLastrowReader, pTaskInfo->id.str);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
pInfo->currentGroupIndex += 1;
|
pInfo->currentGroupIndex += 1;
|
||||||
taosArrayClear(pInfo->pUidList);
|
taosArrayClear(pInfo->pUidList);
|
||||||
|
@ -254,8 +264,8 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
ASSERT((pInfo->retrieveType & CACHESCAN_RETRIEVE_LAST_ROW) == CACHESCAN_RETRIEVE_LAST_ROW);
|
ASSERT((pInfo->retrieveType & CACHESCAN_RETRIEVE_LAST_ROW) == CACHESCAN_RETRIEVE_LAST_ROW);
|
||||||
|
|
||||||
pInfo->pRes->info.id.uid = *(tb_uid_t*)taosArrayGet(pInfo->pUidList, 0);
|
pInfo->pRes->info.id.uid = *(tb_uid_t*)taosArrayGet(pInfo->pUidList, 0);
|
||||||
code = addTagPseudoColumnData(&pInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pInfo->pRes, pInfo->pRes->info.rows,
|
code = addTagPseudoColumnData(&pInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pInfo->pRes,
|
||||||
GET_TASKID(pTaskInfo), NULL);
|
pInfo->pRes->info.rows, GET_TASKID(pTaskInfo), NULL);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
pTaskInfo->code = code;
|
pTaskInfo->code = code;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -280,6 +290,7 @@ void destroyCacheScanOperator(void* param) {
|
||||||
blockDataDestroy(pInfo->pRes);
|
blockDataDestroy(pInfo->pRes);
|
||||||
blockDataDestroy(pInfo->pBufferredRes);
|
blockDataDestroy(pInfo->pBufferredRes);
|
||||||
taosMemoryFree(pInfo->pSlotIds);
|
taosMemoryFree(pInfo->pSlotIds);
|
||||||
|
taosArrayDestroy(pInfo->pCidList);
|
||||||
taosArrayDestroy(pInfo->pUidList);
|
taosArrayDestroy(pInfo->pUidList);
|
||||||
taosArrayDestroy(pInfo->matchInfo.pList);
|
taosArrayDestroy(pInfo->matchInfo.pList);
|
||||||
tableListDestroy(pInfo->pTableList);
|
tableListDestroy(pInfo->pTableList);
|
||||||
|
|
Loading…
Reference in New Issue