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