fix(query): handle the reverse case.

This commit is contained in:
Haojun Liao 2022-08-18 22:57:26 +08:00
parent 04a06d4353
commit 5eae03fcab
1 changed files with 30 additions and 10 deletions

View File

@ -1376,15 +1376,20 @@ static int32_t doMergeBufAndFileRows_Rv(STsdbReader* pReader, STableBlockScanInf
SBlockData* pBlockData = &pReader->status.fileBlockData;
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
int64_t tsLast = getCurrentKeyInLastBlock(pLastBlockReader);
int64_t tsLast = INT64_MIN;
if (pLastBlockReader->lastBlockData.nRow > 0) {
tsLast = getCurrentKeyInLastBlock(pLastBlockReader);
}
TSDBKEY k = TSDBROW_KEY(pRow);
TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex);
SBlockData* pLastBlockData = &pLastBlockReader->lastBlockData;
int64_t minKey = INT64_MAX;
if (minKey > tsLast) {
int64_t minKey = 0;
if (pReader->order == TSDB_ORDER_ASC) {
minKey = INT64_MAX; // chosen the minimum value
if (minKey > tsLast && pLastBlockReader->lastBlockData.nRow > 0) {
minKey = tsLast;
}
@ -1395,6 +1400,20 @@ static int32_t doMergeBufAndFileRows_Rv(STsdbReader* pReader, STableBlockScanInf
if (minKey > key && pBlockData->nRow > 0) {
minKey = key;
}
} else {
minKey = INT64_MIN;
if (minKey < tsLast && pLastBlockReader->lastBlockData.nRow > 0) {
minKey = tsLast;
}
if (minKey < k.ts) {
minKey = k.ts;
}
if (minKey < key && pBlockData->nRow > 0) {
minKey = key;
}
}
bool init = false;
@ -1530,6 +1549,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
return TSDB_CODE_SUCCESS;
}
// todo handle the desc order check
static int32_t doMergeThreeLevelRowsRv(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo, SBlockData* pBlockData, SLastBlockReader* pLastBlockReader) {
SRowMerger merge = {0};
STSRow* pTSRow = NULL;