[td-225] fix error in calculate the qualified block
This commit is contained in:
parent
14a86b4b5e
commit
2ba89e21b3
|
@ -26,7 +26,6 @@
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "queryLog.h"
|
#include "queryLog.h"
|
||||||
#include "qast.h"
|
#include "qast.h"
|
||||||
#include "tfile.h"
|
|
||||||
#include "tlosertree.h"
|
#include "tlosertree.h"
|
||||||
#include "tscompression.h"
|
#include "tscompression.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
|
@ -515,7 +515,7 @@ static int32_t binarySearchForBlock(SCompBlock* pBlock, int32_t numOfBlocks, TSK
|
||||||
return midSlot;
|
return midSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlocks, int32_t type) {
|
static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlocks) {
|
||||||
SFileGroup* fileGroup = pQueryHandle->pFileGroup;
|
SFileGroup* fileGroup = pQueryHandle->pFileGroup;
|
||||||
assert(fileGroup->files[TSDB_FILE_TYPE_HEAD].fname > 0);
|
assert(fileGroup->files[TSDB_FILE_TYPE_HEAD].fname > 0);
|
||||||
|
|
||||||
|
@ -532,13 +532,15 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTables; ++i) {
|
for (int32_t i = 0; i < numOfTables; ++i) {
|
||||||
STableCheckInfo* pCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, i);
|
STableCheckInfo* pCheckInfo = taosArrayGet(pQueryHandle->pTableCheckInfo, i);
|
||||||
|
pCheckInfo->numOfBlocks = 0;
|
||||||
|
|
||||||
SCompIdx* compIndex = &pQueryHandle->rhelper.pCompIdx[pCheckInfo->tableId.tid];
|
SCompIdx* compIndex = &pQueryHandle->rhelper.pCompIdx[pCheckInfo->tableId.tid];
|
||||||
if (compIndex->len == 0 || compIndex->numOfBlocks == 0 ||
|
|
||||||
compIndex->uid != pCheckInfo->tableId.uid) { // no data block in this file, try next file
|
// no data block in this file, try next file
|
||||||
pCheckInfo->numOfBlocks = 0;
|
if (compIndex->len == 0 || compIndex->numOfBlocks == 0 || compIndex->uid != pCheckInfo->tableId.uid) {
|
||||||
continue; // no data blocks in the file belongs to pCheckInfo->pTable
|
continue; // no data blocks in the file belongs to pCheckInfo->pTable
|
||||||
} else {
|
}
|
||||||
|
|
||||||
if (pCheckInfo->compSize < compIndex->len) {
|
if (pCheckInfo->compSize < compIndex->len) {
|
||||||
assert(compIndex->len > 0);
|
assert(compIndex->len > 0);
|
||||||
|
|
||||||
|
@ -554,8 +556,16 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
|
||||||
tsdbLoadCompInfo(&(pQueryHandle->rhelper), (void *)(pCheckInfo->pCompInfo));
|
tsdbLoadCompInfo(&(pQueryHandle->rhelper), (void *)(pCheckInfo->pCompInfo));
|
||||||
SCompInfo* pCompInfo = pCheckInfo->pCompInfo;
|
SCompInfo* pCompInfo = pCheckInfo->pCompInfo;
|
||||||
|
|
||||||
TSKEY s = MIN(pCheckInfo->lastKey, pQueryHandle->window.ekey);
|
TSKEY s = TSKEY_INITIAL_VAL, e = TSKEY_INITIAL_VAL;
|
||||||
TSKEY e = MAX(pCheckInfo->lastKey, pQueryHandle->window.ekey);
|
|
||||||
|
if (ASCENDING_TRAVERSE(pQueryHandle->order)) {
|
||||||
|
assert(pCheckInfo->lastKey >= pQueryHandle->window.ekey && pQueryHandle->window.skey <= pQueryHandle->window.ekey);
|
||||||
|
} else {
|
||||||
|
assert(pCheckInfo->lastKey <= pQueryHandle->window.ekey && pQueryHandle->window.skey >= pQueryHandle->window.ekey);
|
||||||
|
}
|
||||||
|
|
||||||
|
s = MIN(pCheckInfo->lastKey, pQueryHandle->window.ekey);
|
||||||
|
e = MAX(pCheckInfo->lastKey, pQueryHandle->window.ekey);
|
||||||
|
|
||||||
// discard the unqualified data block based on the query time window
|
// discard the unqualified data block based on the query time window
|
||||||
int32_t start = binarySearchForBlock(pCompInfo->blocks, compIndex->numOfBlocks, s, TSDB_ORDER_ASC);
|
int32_t start = binarySearchForBlock(pCompInfo->blocks, compIndex->numOfBlocks, s, TSDB_ORDER_ASC);
|
||||||
|
@ -578,7 +588,6 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
|
||||||
|
|
||||||
(*numOfBlocks) += pCheckInfo->numOfBlocks;
|
(*numOfBlocks) += pCheckInfo->numOfBlocks;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1378,8 +1387,7 @@ static int32_t getDataBlocksInFilesImpl(STsdbQueryHandle* pQueryHandle, bool* ex
|
||||||
int32_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
|
int32_t numOfTables = taosArrayGetSize(pQueryHandle->pTableCheckInfo);
|
||||||
|
|
||||||
while ((pQueryHandle->pFileGroup = tsdbGetFileGroupNext(&pQueryHandle->fileIter)) != NULL) {
|
while ((pQueryHandle->pFileGroup = tsdbGetFileGroupNext(&pQueryHandle->fileIter)) != NULL) {
|
||||||
int32_t type = ASCENDING_TRAVERSE(pQueryHandle->order)? QUERY_RANGE_GREATER_EQUAL:QUERY_RANGE_LESS_EQUAL;
|
if ((code = getFileCompInfo(pQueryHandle, &numOfBlocks)) != TSDB_CODE_SUCCESS) {
|
||||||
if ((code = getFileCompInfo(pQueryHandle, &numOfBlocks, type)) != TSDB_CODE_SUCCESS) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue