Skip to content

Commit ceacd31

Browse files
committed
Fix for unequal nulls bitmap size YQL-17564
1 parent 5594dac commit ceacd31

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

ydb/library/yql/minikql/comp_nodes/mkql_grace_join_imp.cpp

+19-18
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,7 @@ void TTable::Join( TTable & t1, TTable & t2, EJoinKind joinKind, bool hasMoreLef
330330

331331
joinResults.reserve(3 * bucket1->TuplesNum );
332332

333-
ui64 headerSize = JoinTable1->HeaderSize;
334-
ui64 slotSize = headerSize;
333+
ui64 slotSize = headerSize2;
335334

336335
ui64 avgStringsSize = ( 3 * (bucket2->KeyIntVals.size() - bucket2->TuplesNum * headerSize2) ) / ( 2 * bucket2->TuplesNum + 1) + 1;
337336

@@ -417,14 +416,15 @@ void TTable::Join( TTable & t1, TTable & t2, EJoinKind joinKind, bool hasMoreLef
417416
auto slotIt = joinSlots.begin() + slotNum * slotSize;
418417
while (*slotIt != 0 && slotIt != joinSlots.end())
419418
{
419+
420420
bool matchFound = false;
421-
if (keysValSize <= slotSize && !JoinTable1->NumberOfKeyIColumns ) {
421+
if (((keysValSize - nullsSize1) <= (slotSize - nullsSize2)) && !JoinTable1->NumberOfKeyIColumns ) {
422422
if (std::equal(it1 + keyIntOffset1, it1 + keysValSize, slotIt + keyIntOffset2)) {
423423
matchFound = true;
424424
}
425425
}
426426

427-
if (keysValSize > slotSize && !JoinTable1->NumberOfKeyIColumns ) {
427+
if (((keysValSize - nullsSize1) > (slotSize - nullsSize2)) && !JoinTable1->NumberOfKeyIColumns ) {
428428
if (std::equal(it1 + keyIntOffset1, it1 + headerSize1, slotIt + keyIntOffset2)) {
429429
ui64 stringsPos = *(slotIt + headerSize2);
430430
ui64 stringsSize = *(it1 + headerSize1 - 1);
@@ -434,6 +434,7 @@ void TTable::Join( TTable & t1, TTable & t2, EJoinKind joinKind, bool hasMoreLef
434434
}
435435
}
436436

437+
437438
if (JoinTable1->NumberOfKeyIColumns)
438439
{
439440
bool headerMatch = false;
@@ -481,29 +482,29 @@ void TTable::Join( TTable & t1, TTable & t2, EJoinKind joinKind, bool hasMoreLef
481482
matchFound = true;
482483
}
483484

484-
}
485+
}
485486

486-
if (matchFound)
487+
if (matchFound)
488+
{
489+
JoinTuplesIds joinIds;
490+
joinIds.id1 = tuple1Idx;
491+
joinIds.id2 = slotToIdx[(slotIt - joinSlots.begin()) / slotSize];
492+
if (JoinTable2->TableBuckets[bucket].TuplesNum > JoinTable1->TableBuckets[bucket].TuplesNum)
487493
{
488-
JoinTuplesIds joinIds;
489-
joinIds.id1 = tuple1Idx;
490-
joinIds.id2 = slotToIdx[(slotIt - joinSlots.begin()) / slotSize];
491-
if (JoinTable2->TableBuckets[bucket].TuplesNum > JoinTable1->TableBuckets[bucket].TuplesNum)
492-
{
493-
std::swap(joinIds.id1, joinIds.id2);
494-
}
495-
joinResults.emplace_back(joinIds);
494+
std::swap(joinIds.id1, joinIds.id2);
496495
}
497-
498-
slotIt += slotSize;
499-
if (slotIt == joinSlots.end())
500-
slotIt = joinSlots.begin();
496+
joinResults.emplace_back(joinIds);
501497
}
502498

499+
slotIt += slotSize;
500+
if (slotIt == joinSlots.end())
501+
slotIt = joinSlots.begin();
502+
}
503503

504504
it1 += keysValSize;
505505
tuple1Idx ++;
506506
}
507+
507508
std::sort(joinResults.begin(), joinResults.end(), [](JoinTuplesIds a, JoinTuplesIds b)
508509
{
509510
if (a.id1 < b.id1) return true;

0 commit comments

Comments
 (0)