提交 fbd3aac0 编写于 作者: H Haojun Liao

fix(query):set the correct active block index and add some logs.

上级 187735de
......@@ -103,10 +103,20 @@ static SBlockData* loadLastBlock(SLDataIter *pIter, const char* idStr) {
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,12 +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;
}
......@@ -323,8 +336,10 @@ 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;
......@@ -371,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);
}
}
......@@ -394,15 +413,11 @@ 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) {
if (pBlockData->aUid[i] > pIter->uid) {
break;
}
} else {
/*if (pBlockData->aUid[i] > pIter->uid) {
continue;
} else */if (pBlockData->aUid[i] < pIter->uid) {
if (pBlockData->aUid[i] < pIter->uid) {
break;
}
}
......@@ -457,7 +472,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;
}
......
......@@ -845,8 +845,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
if ((pDumpInfo->rowIndex == 0 && asc) || (pDumpInfo->rowIndex == pBlock->nRow - 1 && (!asc))) {
if (asc && pReader->window.skey <= pBlock->minKey.ts) {
//pDumpInfo->rowIndex = 0;
} else
if (!asc && pReader->window.ekey >= pBlock->maxKey.ts) {
} else if (!asc && pReader->window.ekey >= pBlock->maxKey.ts) {
//pDumpInfo->rowIndex = pBlock->nRow - 1;
} else {
int32_t pos = asc ? pBlock->nRow - 1 : 0;
......@@ -1644,6 +1643,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])) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册