Skip to content

Commit

Permalink
Fix for unequal nulls bitmap size YQL-17564 (ydb-platform#1570)
Browse files Browse the repository at this point in the history
  • Loading branch information
aakulaga-ydb authored and EgorkaZ committed Apr 8, 2024
1 parent 29ad95f commit e9829a9
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions ydb/library/yql/minikql/comp_nodes/mkql_grace_join_imp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,7 @@ void TTable::Join( TTable & t1, TTable & t2, EJoinKind joinKind, bool hasMoreLef

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

ui64 headerSize = JoinTable1->HeaderSize;
ui64 slotSize = headerSize;
ui64 slotSize = headerSize2;

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

Expand Down Expand Up @@ -417,14 +416,15 @@ void TTable::Join( TTable & t1, TTable & t2, EJoinKind joinKind, bool hasMoreLef
auto slotIt = joinSlots.begin() + slotNum * slotSize;
while (*slotIt != 0 && slotIt != joinSlots.end())
{

bool matchFound = false;
if (keysValSize <= slotSize && !JoinTable1->NumberOfKeyIColumns ) {
if (((keysValSize - nullsSize1) <= (slotSize - nullsSize2)) && !JoinTable1->NumberOfKeyIColumns ) {
if (std::equal(it1 + keyIntOffset1, it1 + keysValSize, slotIt + keyIntOffset2)) {
matchFound = true;
}
}

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


if (JoinTable1->NumberOfKeyIColumns)
{
bool headerMatch = false;
Expand Down Expand Up @@ -481,29 +482,29 @@ void TTable::Join( TTable & t1, TTable & t2, EJoinKind joinKind, bool hasMoreLef
matchFound = true;
}

}
}

if (matchFound)
if (matchFound)
{
JoinTuplesIds joinIds;
joinIds.id1 = tuple1Idx;
joinIds.id2 = slotToIdx[(slotIt - joinSlots.begin()) / slotSize];
if (JoinTable2->TableBuckets[bucket].TuplesNum > JoinTable1->TableBuckets[bucket].TuplesNum)
{
JoinTuplesIds joinIds;
joinIds.id1 = tuple1Idx;
joinIds.id2 = slotToIdx[(slotIt - joinSlots.begin()) / slotSize];
if (JoinTable2->TableBuckets[bucket].TuplesNum > JoinTable1->TableBuckets[bucket].TuplesNum)
{
std::swap(joinIds.id1, joinIds.id2);
}
joinResults.emplace_back(joinIds);
std::swap(joinIds.id1, joinIds.id2);
}

slotIt += slotSize;
if (slotIt == joinSlots.end())
slotIt = joinSlots.begin();
joinResults.emplace_back(joinIds);
}

slotIt += slotSize;
if (slotIt == joinSlots.end())
slotIt = joinSlots.begin();
}

it1 += keysValSize;
tuple1Idx ++;
}

std::sort(joinResults.begin(), joinResults.end(), [](JoinTuplesIds a, JoinTuplesIds b)
{
if (a.id1 < b.id1) return true;
Expand Down

0 comments on commit e9829a9

Please sign in to comment.