Skip to content

Fix for unequal nulls bitmap size YQL-17564 #1570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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