Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8226#discussion_r37144278
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeJoin.scala
 ---
    @@ -96,9 +103,37 @@ case class SortMergeJoin(
               RowIterator.fromScala(rightIter),
               numRightRows
             )
    -        private[this] val joinRow = new JoinedRow
    +
    +        private[this] val rowJoiner = new JoinedRow
    +        private[this] val unsafeRowJoiner =
    +          GenerateUnsafeRowJoiner.create(leftSchema, rightSchema)
    +
    +        private[this] var joinedRow: InternalRow = _
    +        private[this] val joinRow: (InternalRow, InternalRow) => 
InternalRow = {
    +          if (canUnsafeJoin) {
    +            (currentLeftRow: InternalRow, currentRightRow: InternalRow) => 
{
    +              unsafeRowJoiner.join(currentLeftRow.asInstanceOf[UnsafeRow],
    +                currentRightRow.asInstanceOf[UnsafeRow])
    +            }
    +          } else {
    +            rowJoiner.apply
    +          }
    +        }
    +
    +        private[this] val withRight: (InternalRow) => InternalRow = {
    +          if (canUnsafeJoin) {
    +            (currentRightRow: InternalRow) => {
    +              
unsafeRowJoiner.withRight(currentRightRow.asInstanceOf[UnsafeRow])
    +            }
    +          } else {
    +            rowJoiner.withRight
    +          }
    +        }
    +
             private[this] val resultProjection: (InternalRow) => InternalRow = 
{
    -          if (isUnsafeMode) {
    +          if (canUnsafeJoin) {
    +            identity[InternalRow]
    --- End diff --
    
    Two `UnsafeRows` are joined together as another `UnsafeRow`. So we don't 
need to do `UnsafeProjection` here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to