wankunde commented on code in PR #44660:
URL: https://github.com/apache/spark/pull/44660#discussion_r1464466836
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeJoinExec.scala:
##########
@@ -959,38 +963,53 @@ case class SortMergeJoinExec(
// Scan the left and right buffers to find all matched rows.
val matchRowsInBuffer =
s"""
- |int $leftIndex;
- |int $rightIndex;
- |
- |for ($leftIndex = 0; $leftIndex < $leftBuffer.size(); $leftIndex++) {
+ |while ($leftIndex < $leftBuffer.size()) {
| $leftOutputRow = (InternalRow) $leftBuffer.get($leftIndex);
- | for ($rightIndex = 0; $rightIndex < $rightBuffer.size();
$rightIndex++) {
+ | while ($rightIndex < $rightBuffer.size()) {
| $rightOutputRow = (InternalRow) $rightBuffer.get($rightIndex);
| $conditionCheck {
| $consumeFullOuterJoinRow();
| $leftMatched.set($leftIndex);
| $rightMatched.set($rightIndex);
+ | if (shouldStop()) {
+ | $rightIndex++;
+ | return;
+ | }
| }
+ | $rightIndex++;
| }
- |
+ | $rightIndex = 0;
| if (!$leftMatched.get($leftIndex)) {
|
| $rightOutputRow = null;
| $consumeFullOuterJoinRow();
+ | if (shouldStop()) {
+ | $leftIndex++;
+ | return;
+ | }
| }
+ | $leftIndex++;
|}
|
|$leftOutputRow = null;
- |for ($rightIndex = 0; $rightIndex < $rightBuffer.size();
$rightIndex++) {
+ |while ($rightIndex < $rightBuffer.size()) {
| if (!$rightMatched.get($rightIndex)) {
| // The right row has never matched any left row, join it with
null row
| $rightOutputRow = (InternalRow) $rightBuffer.get($rightIndex);
| $consumeFullOuterJoinRow();
+ | if (shouldStop()) {
+ | $rightIndex++;
+ | return;
+ | }
| }
+ | $rightIndex++;
|}
""".stripMargin
s"""
+ |if ($leftIndex < $leftBuffer.size() || $rightIndex <
$rightBuffer.size()) {
+ | $matchRowsInBuffer
+ |}
Review Comment:
Could we wrap "$matchRowsInBuffer" as a function? There are too many
duplicated code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]