fix(tsdb): check numOfPks before load pk

This commit is contained in:
Haojun Liao 2024-04-11 15:16:21 +08:00
parent 1751b84188
commit a3bbf3ba0e
1 changed files with 30 additions and 24 deletions

View File

@ -399,6 +399,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
rows - i); rows - i);
taosArrayAddBatch(pBlockLoadInfo->info.pCount, tBufferGetDataAt(&block.counts, i * sizeof(int64_t)), rows - i); taosArrayAddBatch(pBlockLoadInfo->info.pCount, tBufferGetDataAt(&block.counts, i * sizeof(int64_t)), rows - i);
if (block.numOfPKs > 0) {
SValue vFirst = {0}, vLast = {0}; SValue vFirst = {0}, vLast = {0};
for (int32_t f = i; f < rows; ++f) { for (int32_t f = i; f < rows; ++f) {
int32_t code = tValueColumnGet(&block.firstKeyPKs[0], f, &vFirst); int32_t code = tValueColumnGet(&block.firstKeyPKs[0], f, &vFirst);
@ -418,9 +419,11 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
tValueDupPayload(&vLast); tValueDupPayload(&vLast);
taosArrayPush(pBlockLoadInfo->info.pLastKey, &vLast); taosArrayPush(pBlockLoadInfo->info.pLastKey, &vLast);
} }
}
} else { } else {
STbStatisRecord record; STbStatisRecord record = {0};
while (i < rows) { while (i < rows) {
tStatisBlockGet(&block, i, &record); tStatisBlockGet(&block, i, &record);
if (record.suid != suid) { if (record.suid != suid) {
@ -433,6 +436,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
taosArrayPush(pBlockLoadInfo->info.pFirstTs, &record.firstKey.ts); taosArrayPush(pBlockLoadInfo->info.pFirstTs, &record.firstKey.ts);
taosArrayPush(pBlockLoadInfo->info.pLastTs, &record.lastKey.ts); taosArrayPush(pBlockLoadInfo->info.pLastTs, &record.lastKey.ts);
if (record.firstKey.numOfPKs > 0) {
SValue s = record.firstKey.pks[0]; SValue s = record.firstKey.pks[0];
tValueDupPayload(&s); tValueDupPayload(&s);
@ -442,6 +446,8 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
tValueDupPayload(&s); tValueDupPayload(&s);
taosArrayPush(pBlockLoadInfo->info.pLastKey, &s); taosArrayPush(pBlockLoadInfo->info.pLastKey, &s);
}
i += 1; i += 1;
} }
} }