提交 6f252d8d 编写于 作者: H Haojun Liao

fix(query): opt perf on last block query.

上级 a5933fc6
...@@ -644,7 +644,6 @@ typedef struct { ...@@ -644,7 +644,6 @@ typedef struct {
} SRowInfo; } SRowInfo;
typedef struct SSttBlockLoadInfo { typedef struct SSttBlockLoadInfo {
int32_t sttFileIndex;
SBlockData blockData[2]; SBlockData blockData[2];
SArray *aSttBlk; SArray *aSttBlk;
int32_t blockIndex[2]; // to denote the loaded block in the corresponding position. int32_t blockIndex[2]; // to denote the loaded block in the corresponding position.
......
...@@ -90,22 +90,23 @@ static SBlockData* loadBlockIfMissing(SLDataIter *pIter) { ...@@ -90,22 +90,23 @@ static SBlockData* loadBlockIfMissing(SLDataIter *pIter) {
int32_t code = 0; int32_t code = 0;
SSttBlockLoadInfo* pInfo = pIter->pBlockLoadInfo; SSttBlockLoadInfo* pInfo = pIter->pBlockLoadInfo;
if (pInfo->blockIndex[0] == pIter->iStt) { if (pInfo->blockIndex[0] == pIter->iSttBlk) {
return &pInfo->blockData[0]; return &pInfo->blockData[0];
} }
if (pInfo->blockIndex[1] == pIter->iStt) { if (pInfo->blockIndex[1] == pIter->iSttBlk) {
return &pInfo->blockData[1]; return &pInfo->blockData[1];
} }
pInfo->currentLoadBlockIndex ^= 1; pInfo->currentLoadBlockIndex ^= 1;
if (pIter->pSttBlk != NULL) { // current block not loaded yet if (pIter->pSttBlk != NULL) { // current block not loaded yet
code = tsdbReadSttBlock(pIter->pReader, pIter->iStt, pIter->pSttBlk, &pInfo->blockData[pInfo->currentLoadBlockIndex]); code = tsdbReadSttBlock(pIter->pReader, pIter->iStt, pIter->pSttBlk, &pInfo->blockData[pInfo->currentLoadBlockIndex]);
tsdbDebug("read last block, index:%d, last file index:%d", pIter->iSttBlk, pIter->iStt);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
goto _exit; goto _exit;
} }
pInfo->blockIndex[pInfo->currentLoadBlockIndex] = pIter->iStt; pInfo->blockIndex[pInfo->currentLoadBlockIndex] = pIter->iSttBlk;
pIter->iRow = (pIter->backward) ? pInfo->blockData[pInfo->currentLoadBlockIndex].nRow : -1; pIter->iRow = (pIter->backward) ? pInfo->blockData[pInfo->currentLoadBlockIndex].nRow : -1;
} }
...@@ -136,26 +137,13 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t ...@@ -136,26 +137,13 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
(*pIter)->timeWindow = *pTimeWindow; (*pIter)->timeWindow = *pTimeWindow;
(*pIter)->pBlockLoadInfo = pBlockLoadInfo; (*pIter)->pBlockLoadInfo = pBlockLoadInfo;
if (taosArrayGetSize(pBlockLoadInfo->aSttBlk) == 0) {
if (pBlockLoadInfo->aSttBlk == NULL) {
// loaded into the common shared objects
pBlockLoadInfo->aSttBlk = taosArrayInit(0, sizeof(SSttBlk));
if (pBlockLoadInfo->aSttBlk == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
code = tsdbReadSttBlk(pReader, iStt, pBlockLoadInfo->aSttBlk); code = tsdbReadSttBlk(pReader, iStt, pBlockLoadInfo->aSttBlk);
if (code) { if (code) {
goto _exit; goto _exit;
} }
} }
code = tsdbReadSttBlk(pReader, iStt, pBlockLoadInfo->aSttBlk);
if (code) {
goto _exit;
}
size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk); size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
// find the start block // find the start block
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册