提交 5cac7c7a 编写于 作者: H Haojun Liao

fix(tsdb): fix error in query super table.

上级 a5049b48
...@@ -582,9 +582,9 @@ static int32_t initFilesetIterator(SFilesetIter* pIter, TFileSetArray* pFileSetA ...@@ -582,9 +582,9 @@ static int32_t initFilesetIterator(SFilesetIter* pIter, TFileSetArray* pFileSetA
static int32_t filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader, bool* hasNext) { static int32_t filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader, bool* hasNext) {
bool asc = ASCENDING_TRAVERSE(pIter->order); bool asc = ASCENDING_TRAVERSE(pIter->order);
int32_t step = asc ? 1 : -1; int32_t step = asc ? 1 : -1;
pIter->index += step;
int32_t code = 0; int32_t code = 0;
pIter->index += step;
if ((asc && pIter->index >= pIter->numOfFiles) || ((!asc) && pIter->index < 0)) { if ((asc && pIter->index >= pIter->numOfFiles) || ((!asc) && pIter->index < 0)) {
*hasNext = false; *hasNext = false;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -874,7 +874,7 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFileReader* pFileRead ...@@ -874,7 +874,7 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFileReader* pFileRead
} }
const TBrinBlkArray* pBlkArray = NULL; const TBrinBlkArray* pBlkArray = NULL;
int32_t code = tsdbDataFileReadBrinBlk(pFileReader, &pBlkArray); int32_t code = tsdbDataFileReadBrinBlk(pFileReader, &pBlkArray);
LRUHandle* handle = NULL; LRUHandle* handle = NULL;
#if 0 #if 0
...@@ -895,14 +895,17 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFileReader* pFileRead ...@@ -895,14 +895,17 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFileReader* pFileRead
// todo binary search to the start position // todo binary search to the start position
int64_t et1 = taosGetTimestampUs(); int64_t et1 = taosGetTimestampUs();
SBrinBlk* pBrinBlk = NULL; SBrinBlk* pBrinBlk = NULL;
STableUidList* pList = &pReader->status.uidList; STableUidList* pList = &pReader->status.uidList;
bool newBlk = false;
int32_t i = 0, j = 0; int32_t i = 0, j = 0;
while (i < pBlkArray->size && j < numOfTables) { while (i < pBlkArray->size && j < numOfTables) {
pBrinBlk = &pBlkArray->data[i]; pBrinBlk = &pBlkArray->data[i];
if (pBrinBlk->maxTbid.suid < pReader->suid) { if (pBrinBlk->maxTbid.suid < pReader->suid) {
i += 1; i += 1;
newBlk = true;
continue; continue;
} }
...@@ -917,30 +920,39 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFileReader* pFileRead ...@@ -917,30 +920,39 @@ static int32_t doLoadBlockIndex(STsdbReader* pReader, SDataFileReader* pFileRead
continue; continue;
} }
// this block belongs to a table that is not queried. // this block belongs to a table that is not queried.
STableBlockScanInfo* pScanInfo = getTableBlockScanInfo(pReader->status.pTableMap, pList->tableUidList[j], pReader->idStr); STableBlockScanInfo* pScanInfo =
if (pScanInfo == NULL) { getTableBlockScanInfo(pReader->status.pTableMap, pList->tableUidList[j], pReader->idStr);
// tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle); if (pScanInfo == NULL) {
return terrno; // tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle);
} return terrno;
}
if (pScanInfo->pBlockList == NULL) { if (pScanInfo->pBlockList == NULL) {
pScanInfo->pBlockList = taosArrayInit(4, sizeof(SBrinRecord)); pScanInfo->pBlockList = taosArrayInit(4, sizeof(SBrinRecord));
} }
if (taosArrayGetSize(pIndexList) == 0) {
taosArrayPush(pIndexList, pBrinBlk); taosArrayPush(pIndexList, pBrinBlk);
j += 1; } else {
if (newBlk) {
taosArrayPush(pIndexList, pBrinBlk);
}
newBlk = false;
} }
j += 1;
}
int64_t et2 = taosGetTimestampUs(); int64_t et2 = taosGetTimestampUs();
tsdbDebug("load block index for %d/%d tables completed, elapsed time:%.2f ms, set BrinBlk:%.2f ms, size:%.2f Kb %s", tsdbDebug("load block index for %d/%d tables completed, elapsed time:%.2f ms, set BrinBlk:%.2f ms, size:%.2f Kb %s",
numOfTables, (int32_t)pBlkArray->size, (et1 - st) / 1000.0, (et2 - et1) / 1000.0, pBlkArray->size * sizeof(SBrinBlk) / 1024.0, numOfTables, (int32_t)pBlkArray->size, (et1 - st) / 1000.0, (et2 - et1) / 1000.0,
pReader->idStr); pBlkArray->size * sizeof(SBrinBlk) / 1024.0, pReader->idStr);
pReader->cost.headFileLoadTime += (et1 - st) / 1000.0; pReader->cost.headFileLoadTime += (et1 - st) / 1000.0;
_end: _end:
// tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle); // tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle);
return code; return code;
} }
...@@ -1047,12 +1059,21 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN ...@@ -1047,12 +1059,21 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN
while (pRecord->uid > uid && k < numOfTables) { while (pRecord->uid > uid && k < numOfTables) {
k += 1; k += 1;
if (k >= numOfTables) {
break;
}
uid = pReader->status.uidList.tableUidList[k];
} }
if (k >= numOfTables) { if (k >= numOfTables) {
break; break;
} }
if (pRecord->uid < uid) {
continue;
}
ASSERT(pRecord->suid == pReader->suid && uid == pRecord->uid); ASSERT(pRecord->suid == pReader->suid && uid == pRecord->uid);
STableBlockScanInfo* pScanInfo = getTableBlockScanInfo(pReader->status.pTableMap, uid, pReader->idStr); STableBlockScanInfo* pScanInfo = getTableBlockScanInfo(pReader->status.pTableMap, uid, pReader->idStr);
...@@ -1743,6 +1764,8 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte ...@@ -1743,6 +1764,8 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
int32_t index = sup.indexPerTable[pos]++; int32_t index = sup.indexPerTable[pos]++;
SFileDataBlockInfo blockInfo = {.uid = sup.pDataBlockInfo[pos][index].uid, .tbBlockIdx = index}; SFileDataBlockInfo blockInfo = {.uid = sup.pDataBlockInfo[pos][index].uid, .tbBlockIdx = index};
blockInfo.record = *(SBrinRecord*)taosArrayGet(sup.pDataBlockInfo[pos][index].pInfo->pBlockList, index);
taosArrayPush(pBlockIter->blockList, &blockInfo); taosArrayPush(pBlockIter->blockList, &blockInfo);
// set data block index overflow, in order to disable the offset comparator // set data block index overflow, in order to disable the offset comparator
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册