tsdb/cache: new load tomb callback from tsdb mergetree
This commit is contained in:
parent
27b8671f97
commit
a05383e29e
|
|
@ -802,6 +802,10 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead
|
|||
STimeWindow *pTimeWindow, SVersionRange *pVerRange, SSttBlockLoadInfo *pBlockLoadInfo,
|
||||
bool destroyLoadInfo, const char *idStr, bool strictTimeRange, SLDataIter *pLDataIter);
|
||||
|
||||
struct SSttFileReader;
|
||||
typedef int32_t (*_load_tomb_fn)(STsdbReader *pReader, struct SSttFileReader *pSttFileReader,
|
||||
SSttBlockLoadInfo *pLoadInfo);
|
||||
|
||||
typedef struct {
|
||||
int8_t backward;
|
||||
STsdb *pTsdb;
|
||||
|
|
@ -815,6 +819,7 @@ typedef struct {
|
|||
STSchema *pSchema;
|
||||
int16_t *pCols;
|
||||
int32_t numOfCols;
|
||||
_load_tomb_fn loadTombFn;
|
||||
void *pReader;
|
||||
void *idstr;
|
||||
} SMergeTreeConf;
|
||||
|
|
@ -851,7 +856,6 @@ typedef struct STsdbReaderInfo {
|
|||
typedef struct SCacheRowsReader {
|
||||
STsdb *pTsdb;
|
||||
STsdbReaderInfo info;
|
||||
int8_t cacheReader; // always true for cache reader
|
||||
TdThreadMutex readerMutex;
|
||||
SVnode *pVnode;
|
||||
STSchema *pSchema;
|
||||
|
|
|
|||
|
|
@ -1720,6 +1720,24 @@ typedef struct {
|
|||
SMergeTree *pMergeTree;
|
||||
} SFSLastIter;
|
||||
|
||||
static int32_t loadSttTombData(STsdbReader *pReader, SSttFileReader *pSttFileReader, SSttBlockLoadInfo *pLoadInfo) {
|
||||
int32_t code = 0;
|
||||
/*
|
||||
if (pLoadInfo->pTombBlockArray == NULL) {
|
||||
pLoadInfo->pTombBlockArray = taosArrayInit(4, POINTER_BYTES);
|
||||
}
|
||||
|
||||
const TTombBlkArray *pBlkArray = NULL;
|
||||
int32_t code = tsdbSttFileReadTombBlk(pSttFileReader, &pBlkArray);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
return doLoadTombDataFromTombBlk(pBlkArray, pReader, pSttFileReader, false);
|
||||
*/
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t lastIterOpen(SFSLastIter *iter, STFileSet *pFileSet, STsdb *pTsdb, STSchema *pTSchema, tb_uid_t suid,
|
||||
tb_uid_t uid, SCacheRowsReader *pr, int64_t lastTs, int16_t *aCols, int nCols) {
|
||||
int32_t code = 0;
|
||||
|
|
@ -1742,6 +1760,7 @@ static int32_t lastIterOpen(SFSLastIter *iter, STFileSet *pFileSet, STsdb *pTsdb
|
|||
.pSttFileBlockIterArray = pr->pLDataIterArray,
|
||||
.pCols = aCols,
|
||||
.numOfCols = nCols,
|
||||
.loadTombFn = loadSttTombData,
|
||||
.pReader = pr,
|
||||
.idstr = pr->idstr,
|
||||
};
|
||||
|
|
@ -2742,6 +2761,7 @@ static int32_t nextRowIterGet(CacheNextRowIter *pIter, TSDBROW **ppRow, bool *pI
|
|||
for (int i = 0; i < nMax; ++i) {
|
||||
TSDBKEY maxKey1 = TSDBROW_KEY(max[i]);
|
||||
|
||||
// TODO: build skyline here
|
||||
bool deleted = tsdbKeyDeleted(&maxKey1, pIter->pSkyline, &pIter->iSkyline);
|
||||
if (!deleted) {
|
||||
iMerge[nMerge] = iMax[i];
|
||||
|
|
|
|||
|
|
@ -191,7 +191,6 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList,
|
|||
taosThreadMutexInit(&p->readerMutex, NULL);
|
||||
|
||||
p->lastTs = INT64_MIN;
|
||||
p->cacheReader = 1;
|
||||
|
||||
*pReader = p;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -193,7 +193,8 @@ static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) {
|
|||
int64_t st = taosGetTimestampUs();
|
||||
|
||||
SBlockData *pBlock = &pInfo->blockData[pInfo->currentLoadBlockIndex];
|
||||
code = tsdbSttFileReadBlockDataByColumn(pIter->pReader, pIter->pSttBlk, pBlock, pInfo->pSchema, &pInfo->colIds[1], pInfo->numOfCols - 1);
|
||||
code = tsdbSttFileReadBlockDataByColumn(pIter->pReader, pIter->pSttBlk, pBlock, pInfo->pSchema, &pInfo->colIds[1],
|
||||
pInfo->numOfCols - 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _exit;
|
||||
}
|
||||
|
|
@ -393,9 +394,10 @@ static int32_t loadSttTombBlockData(SSttFileReader* pSttFileReader, uint64_t sui
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t tLDataIterOpen2(struct SLDataIter *pIter, SSttFileReader *pSttFileReader, int32_t iStt, int8_t backward, uint64_t suid,
|
||||
uint64_t uid, STimeWindow *pTimeWindow, SVersionRange *pRange, SSttBlockLoadInfo *pBlockLoadInfo,
|
||||
const char *idStr, bool strictTimeRange, void* pReader1) {
|
||||
int32_t tLDataIterOpen2(struct SLDataIter *pIter, SSttFileReader *pSttFileReader, int32_t iStt, int8_t backward,
|
||||
uint64_t suid, uint64_t uid, STimeWindow *pTimeWindow, SVersionRange *pRange,
|
||||
SSttBlockLoadInfo *pBlockLoadInfo, const char *idStr, bool strictTimeRange,
|
||||
_load_tomb_fn loadTombFn, void *pReader1) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
pIter->uid = uid;
|
||||
|
|
@ -424,7 +426,8 @@ int32_t tLDataIterOpen2(struct SLDataIter *pIter, SSttFileReader *pSttFileReader
|
|||
return code;
|
||||
}
|
||||
|
||||
code = loadSttTombDataForAll(pReader1, pIter->pReader, pBlockLoadInfo);
|
||||
// code = loadSttTombDataForAll(pReader1, pIter->pReader, pBlockLoadInfo);
|
||||
code = loadTombFn(pReader1, pIter->pReader, pBlockLoadInfo);
|
||||
|
||||
double el = (taosGetTimestampUs() - st) / 1000.0;
|
||||
tsdbDebug("load the last file info completed, elapsed time:%.2fms, %s", el, idStr);
|
||||
|
|
@ -507,8 +510,8 @@ void tLDataIterNextBlock(SLDataIter *pIter, const char *idStr) {
|
|||
if (index != -1) {
|
||||
pIter->iSttBlk = index;
|
||||
pIter->pSttBlk = (SSttBlk *)taosArrayGet(pIter->pBlockLoadInfo->aSttBlk, pIter->iSttBlk);
|
||||
tsdbDebug("try next last file block:%d from stt fileIdx:%d, trigger by uid:%" PRIu64 ", file index:%d, %s", pIter->iSttBlk,
|
||||
oldIndex, pIter->uid, pIter->iStt, idStr);
|
||||
tsdbDebug("try next last file block:%d from stt fileIdx:%d, trigger by uid:%" PRIu64 ", file index:%d, %s",
|
||||
pIter->iSttBlk, oldIndex, pIter->uid, pIter->iStt, idStr);
|
||||
} else {
|
||||
tsdbDebug("no more last block qualified, uid:%" PRIu64 ", file index:%d, %s", pIter->uid, oldIndex, idStr);
|
||||
}
|
||||
|
|
@ -785,7 +788,8 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf* pConf) {
|
|||
|
||||
memset(pIter, 0, sizeof(SLDataIter));
|
||||
code = tLDataIterOpen2(pIter, pSttFileReader, i, pMTree->backward, pConf->suid, pConf->uid, &pConf->timewindow,
|
||||
&pConf->verRange, pLoadInfo, pMTree->idStr, pConf->strictTimeRange, pConf->pReader);
|
||||
&pConf->verRange, pLoadInfo, pMTree->idStr, pConf->strictTimeRange, pConf->loadTombFn,
|
||||
pConf->pReader);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _end;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2108,6 +2108,7 @@ static bool initLastBlockReader(SLastBlockReader* pLBlockReader, STableBlockScan
|
|||
.pSttFileBlockIterArray = pReader->status.pLDataIterArray,
|
||||
.pCols = pReader->suppInfo.colId,
|
||||
.numOfCols = pReader->suppInfo.numOfCols,
|
||||
.loadTombFn = loadSttTombDataForAll,
|
||||
.pReader = pReader,
|
||||
.idstr = pReader->idStr,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -186,7 +186,6 @@ typedef struct SReaderStatus {
|
|||
struct STsdbReader {
|
||||
STsdb* pTsdb;
|
||||
STsdbReaderInfo info;
|
||||
int8_t cacheReader; // always false for tsdb reader
|
||||
TdThreadMutex readerMutex;
|
||||
EReaderStatus flag;
|
||||
int32_t code;
|
||||
|
|
|
|||
Loading…
Reference in New Issue