fix(tsdb): fix error in tsdbread.

This commit is contained in:
Haojun Liao 2024-04-07 14:46:22 +08:00
parent 3fab74f21b
commit 16c17bbf72
3 changed files with 19 additions and 20 deletions

View File

@ -114,10 +114,10 @@ int32_t pkCompEx(__compar_fn_t comparFn, SRowKey* p1, SRowKey* p2) {
if (p1->pks[0].nData == p2->pks[0].nData) { if (p1->pks[0].nData == p2->pks[0].nData) {
return 0; return 0;
} else { } else {
return p1->pks[0].nData > p2->pks[0].nData?1:-1; return p1->pks[0].nData > p2->pks[0].nData ? 1 : -1;
} }
} else { } else {
return ret > 0? 1:-1; return ret > 0 ? 1 : -1;
} }
} else { } else {
return comparFn(&p1->pks[0].val, &p2->pks[0].val); return comparFn(&p1->pks[0].val, &p2->pks[0].val);

View File

@ -992,39 +992,39 @@ static bool overlapWithTimeWindow(STimeWindow* p1, STimeWindow* pQueryWindow, ST
} }
static int32_t sortUidComparFn(const void* p1, const void* p2) { static int32_t sortUidComparFn(const void* p1, const void* p2) {
const STimeWindow* px1 = p1; const SSttKeyRange* px1 = p1;
const STimeWindow* px2 = p2; const SSttKeyRange* px2 = p2;
if (px1->skey == px2->skey) {
return 0; int32_t ret = tRowKeyCompare(&px1, px2);
} else { return ret;
return px1->skey < px2->skey ? -1 : 1;
}
} }
bool isCleanSttBlock(SArray* pTimewindowList, STimeWindow* pQueryWindow, STableBlockScanInfo* pScanInfo, bool isCleanSttBlock(SArray* pKeyRangeList, STimeWindow* pQueryWindow, STableBlockScanInfo* pScanInfo,
int32_t order) { int32_t order) {
// check if it overlap with del skyline // check if it overlap with del skyline
taosArraySort(pTimewindowList, sortUidComparFn); taosArraySort(pKeyRangeList, sortUidComparFn);
int32_t num = taosArrayGetSize(pTimewindowList); int32_t num = taosArrayGetSize(pKeyRangeList);
if (num == 0) { if (num == 0) {
return false; return false;
} }
STimeWindow* p = taosArrayGet(pTimewindowList, 0); SSttKeyRange* pRange = taosArrayGet(pKeyRangeList, 0);
if (overlapWithTimeWindow(p, pQueryWindow, pScanInfo, order)) { STimeWindow w = {.skey = pRange->skey.ts, .ekey = pRange->ekey.ts};
if (overlapWithTimeWindow(&w, pQueryWindow, pScanInfo, order)) {
return false; return false;
} }
for (int32_t i = 0; i < num - 1; ++i) { for (int32_t i = 0; i < num - 1; ++i) {
STimeWindow* p1 = taosArrayGet(pTimewindowList, i); SSttKeyRange* p1 = taosArrayGet(pKeyRangeList, i);
STimeWindow* p2 = taosArrayGet(pTimewindowList, i + 1); SSttKeyRange* p2 = taosArrayGet(pKeyRangeList, i + 1);
if (p1->ekey >= p2->skey) { if (p1->ekey.ts >= p2->skey.ts) {
return false; return false;
} }
bool overlap = overlapWithTimeWindow(p2, pQueryWindow, pScanInfo, order); STimeWindow w2 = {.skey = p2->skey.ts, .ekey = p2->ekey.ts};
bool overlap = overlapWithTimeWindow(&w2, pQueryWindow, pScanInfo, order);
if (overlap) { if (overlap) {
return false; return false;
} }

View File

@ -520,9 +520,8 @@ static void doWindowBorderInterpolation(SIntervalAggOperatorInfo* pInfo, SSDataB
// duplicated ts row does not involve in the interpolation of end value for current time window // duplicated ts row does not involve in the interpolation of end value for current time window
int32_t x = endRowIndex; int32_t x = endRowIndex;
while(x >= 0) { while(x > 0) {
if (tsCols[x] == tsCols[x-1]) { if (tsCols[x] == tsCols[x-1]) {
x -= 1; x -= 1;
} else { } else {
endRowIndex = x; endRowIndex = x;