Merge pull request #17331 from taosdata/feature/3_liaohj
fix(query):set the correct active block index and add some logs.
This commit is contained in:
commit
260ca17337
|
@ -101,12 +101,22 @@ void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
|
|||
static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) {
|
||||
int32_t code = 0;
|
||||
|
||||
SSttBlockLoadInfo *pInfo = pIter->pBlockLoadInfo;
|
||||
if (pInfo->blockIndex[0] == pIter->iSttBlk) {
|
||||
SSttBlockLoadInfo* pInfo = pIter->pBlockLoadInfo;
|
||||
if (pInfo->blockIndex[0] == pIter->iSttBlk) {
|
||||
if (pInfo->currentLoadBlockIndex != 0) {
|
||||
tsdbDebug("current load index is set to 0, block index:%d, file index:%d, due to uid:%" PRIu64 ", load data, %s",
|
||||
pIter->iSttBlk, pIter->iStt, pIter->uid, idStr);
|
||||
pInfo->currentLoadBlockIndex = 0;
|
||||
}
|
||||
return &pInfo->blockData[0];
|
||||
}
|
||||
|
||||
if (pInfo->blockIndex[1] == pIter->iSttBlk) {
|
||||
if (pInfo->currentLoadBlockIndex != 1) {
|
||||
tsdbDebug("current load index is set to 1, block index:%d, file index:%d, due to uid:%"PRIu64", load data, %s",
|
||||
pIter->iSttBlk, pIter->iStt, pIter->uid, idStr);
|
||||
pInfo->currentLoadBlockIndex = 1;
|
||||
}
|
||||
return &pInfo->blockData[1];
|
||||
}
|
||||
|
||||
|
@ -130,13 +140,15 @@ static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) {
|
|||
pInfo->elapsedTime += el;
|
||||
pInfo->loadBlocks += 1;
|
||||
|
||||
tsdbDebug("read last block, index:%d, last file index:%d, elapsed time:%.2f ms, %s", pIter->iSttBlk, pIter->iStt,
|
||||
el, idStr);
|
||||
tsdbDebug("read last block, total load:%d, trigger by uid:%"PRIu64", last file index:%d, last block index:%d, entry:%d, %p, elapsed time:%.2f ms, %s",
|
||||
pInfo->loadBlocks, pIter->uid, pIter->iStt, pIter->iSttBlk, pInfo->currentLoadBlockIndex, pBlock, el, idStr);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
pInfo->blockIndex[pInfo->currentLoadBlockIndex] = pIter->iSttBlk;
|
||||
tsdbDebug("last block index list:%d, %d, %s", pInfo->blockIndex[0], pInfo->blockIndex[1], idStr);
|
||||
|
||||
pIter->iRow = (pIter->backward) ? pInfo->blockData[pInfo->currentLoadBlockIndex].nRow : -1;
|
||||
}
|
||||
|
||||
|
@ -324,8 +336,10 @@ _exit:
|
|||
|
||||
void tLDataIterClose(SLDataIter *pIter) { taosMemoryFree(pIter); }
|
||||
|
||||
void tLDataIterNextBlock(SLDataIter *pIter) {
|
||||
void tLDataIterNextBlock(SLDataIter *pIter, const char* idStr) {
|
||||
int32_t step = pIter->backward ? -1 : 1;
|
||||
int32_t oldIndex = pIter->iSttBlk;
|
||||
|
||||
pIter->iSttBlk += step;
|
||||
|
||||
int32_t index = -1;
|
||||
|
@ -372,6 +386,10 @@ void tLDataIterNextBlock(SLDataIter *pIter) {
|
|||
if (index != -1) {
|
||||
pIter->iSttBlk = index;
|
||||
pIter->pSttBlk = (SSttBlk *)taosArrayGet(pIter->pBlockLoadInfo->aSttBlk, pIter->iSttBlk);
|
||||
tsdbDebug("try next last file block:%d from %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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,16 +414,10 @@ static void findNextValidRow(SLDataIter *pIter, const char *idStr) {
|
|||
for (; i < pBlockData->nRow && i >= 0; i += step) {
|
||||
if (pBlockData->aUid != NULL) {
|
||||
if (!pIter->backward) {
|
||||
/*if (pBlockData->aUid[i] < pIter->uid) {
|
||||
continue;
|
||||
} else */
|
||||
if (pBlockData->aUid[i] > pIter->uid) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/*if (pBlockData->aUid[i] > pIter->uid) {
|
||||
continue;
|
||||
} else */
|
||||
if (pBlockData->aUid[i] < pIter->uid) {
|
||||
break;
|
||||
}
|
||||
|
@ -461,7 +473,7 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) {
|
|||
findNextValidRow(pIter, idStr);
|
||||
|
||||
if (pIter->iRow >= pBlockData->nRow || pIter->iRow < 0) {
|
||||
tLDataIterNextBlock(pIter);
|
||||
tLDataIterNextBlock(pIter, idStr);
|
||||
if (pIter->pSttBlk == NULL) { // no more data
|
||||
goto _exit;
|
||||
}
|
||||
|
|
|
@ -1645,6 +1645,7 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
|
|||
STSRow* pTSRow = NULL;
|
||||
SRowMerger merge = {0};
|
||||
TSDBROW fRow = tMergeTreeGetRow(&pLastBlockReader->mergeTree);
|
||||
tsdbTrace("fRow ptr:%p, %d, uid:%"PRIu64", %s", fRow.pBlockData, fRow.iRow, pLastBlockReader->uid, pReader->idStr);
|
||||
|
||||
// only last block exists
|
||||
if ((!mergeBlockData) || (tsLastBlock != pBlockData->aTSKEY[pDumpInfo->rowIndex])) {
|
||||
|
|
Loading…
Reference in New Issue