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

    https://github.com/apache/spark/pull/12102#discussion_r58289671
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/HashJoin.scala ---
    @@ -113,166 +114,112 @@ trait HashJoin {
       protected def buildSideKeyGenerator: Projection =
         UnsafeProjection.create(rewriteKeyExpr(buildKeys), buildPlan.output)
     
    -  protected def streamSideKeyGenerator: Projection =
    +  protected def streamSideKeyGenerator: UnsafeProjection =
         UnsafeProjection.create(rewriteKeyExpr(streamedKeys), 
streamedPlan.output)
     
       @transient private[this] lazy val boundCondition = if 
(condition.isDefined) {
    -    newPredicate(condition.getOrElse(Literal(true)), left.output ++ 
right.output)
    +    newPredicate(condition.get, streamedPlan.output ++ buildPlan.output)
       } else {
         (r: InternalRow) => true
       }
     
    -  protected def createResultProjection: (InternalRow) => InternalRow =
    -    UnsafeProjection.create(self.schema)
    -
    -  protected def hashJoin(
    -      streamIter: Iterator[InternalRow],
    -      hashedRelation: HashedRelation,
    -      numOutputRows: LongSQLMetric): Iterator[InternalRow] = {
    -    new Iterator[InternalRow] {
    -      private[this] var currentStreamedRow: InternalRow = _
    -      private[this] var currentHashMatches: Seq[InternalRow] = _
    -      private[this] var currentMatchPosition: Int = -1
    -
    -      // Mutable per row objects.
    -      private[this] val joinRow = new JoinedRow
    -      private[this] val resultProjection = createResultProjection
    -
    -      private[this] val joinKeys = streamSideKeyGenerator
    -
    -      override final def hasNext: Boolean = {
    -        while (true) {
    -          // check if it's end of current matches
    -          if (currentHashMatches != null && currentMatchPosition == 
currentHashMatches.length) {
    -            currentHashMatches = null
    -            currentMatchPosition = -1
    -          }
    -
    -          // find the next match
    -          while (currentHashMatches == null && streamIter.hasNext) {
    -            currentStreamedRow = streamIter.next()
    -            val key = joinKeys(currentStreamedRow)
    -            if (!key.anyNull) {
    -              currentHashMatches = hashedRelation.get(key)
    -              if (currentHashMatches != null) {
    -                currentMatchPosition = 0
    -              }
    -            }
    -          }
    -          if (currentHashMatches == null) {
    -            return false
    -          }
    -
    -          // found some matches
    -          buildSide match {
    -            case BuildRight => joinRow(currentStreamedRow, 
currentHashMatches(currentMatchPosition))
    -            case BuildLeft => 
joinRow(currentHashMatches(currentMatchPosition), currentStreamedRow)
    -          }
    -          if (boundCondition(joinRow)) {
    -            return true
    -          } else {
    -            currentMatchPosition += 1
    -          }
    -        }
    -        false  // unreachable
    -      }
    -
    -      override final def next(): InternalRow = {
    -        // next() could be called without calling hasNext()
    -        if (hasNext) {
    -          currentMatchPosition += 1
    -          numOutputRows += 1
    -          resultProjection(joinRow)
    -        } else {
    -          throw new NoSuchElementException
    -        }
    -      }
    +  protected def createResultProjection: (InternalRow) => InternalRow = {
    --- End diff --
    
    why is this a function that returns a function, rather than a function?


---
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