fix: multi row same ts join

This commit is contained in:
shenglian zhou 2022-07-27 21:42:35 +08:00
parent 6cb92ef6ee
commit c061cd2fe2
1 changed files with 7 additions and 5 deletions

View File

@ -151,11 +151,11 @@ typedef struct SRowLocation {
int32_t pos; int32_t pos;
} SRowLocation; } SRowLocation;
static int32_t mergeJoinGetBlockRowsEqualTs(SSDataBlock* pBlock, int16_t slotId, int32_t startPos, int64_t timestamp, static int32_t mergeJoinGetBlockRowsEqualTs(SSDataBlock* pBlock, int16_t tsSlotId, int32_t startPos, int64_t timestamp,
SArray* pPosArray) { int32_t* pEndPos, SArray* pRowLocations, SArray* createdBlocks) {
int32_t numRows = pBlock->info.rows; int32_t numRows = pBlock->info.rows;
ASSERT(startPos < numRows); ASSERT(startPos < numRows);
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, tsSlotId);
int32_t i = startPos; int32_t i = startPos;
for (; i < numRows; ++i) { for (; i < numRows; ++i) {
@ -165,16 +165,18 @@ static int32_t mergeJoinGetBlockRowsEqualTs(SSDataBlock* pBlock, int16_t slotId,
} }
} }
int32_t endPos = i; int32_t endPos = i;
*pEndPos = endPos;
SSDataBlock* block = pBlock; SSDataBlock* block = pBlock;
if (endPos - startPos > 1) { if (endPos == numRows) {
block = blockDataExtractBlock(pBlock, startPos, endPos - startPos); block = blockDataExtractBlock(pBlock, startPos, endPos - startPos);
taosArrayPush(createdBlocks, &block);
} }
SRowLocation location = {0}; SRowLocation location = {0};
for (int32_t j = startPos; j < endPos; ++j) { for (int32_t j = startPos; j < endPos; ++j) {
location.pDataBlock = block; location.pDataBlock = block;
location.pos = j; location.pos = j;
taosArrayPush(pPosArray, &location); taosArrayPush(pRowLocations, &location);
} }
return 0; return 0;
} }