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

    https://github.com/apache/spark/pull/1147#discussion_r15678780
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/joins.scala ---
    @@ -138,6 +267,67 @@ trait HashJoin {
     
     /**
      * :: DeveloperApi ::
    + * Performs a hash join of two child relations by shuffling the data using 
the join keys.
    + * This operator requires loading both tables into memory.
    + */
    +@DeveloperApi
    +case class HashOuterJoin(
    +    leftKeys: Seq[Expression],
    +    rightKeys: Seq[Expression],
    +    joinType: JoinType,
    +    condition: Option[Expression],
    +    left: SparkPlan,
    +    right: SparkPlan) extends BinaryRepeatableIteratorNode {
    +
    +  override def outputPartitioning: Partitioning = left.outputPartitioning
    +
    +  override def requiredChildDistribution =
    +    ClusteredDistribution(leftKeys) :: ClusteredDistribution(rightKeys) :: 
Nil
    +
    +  def output = left.output ++ right.output
    +
    +  private[this] def buildHashTable(iter: Iterator[Row], keyGenerator: 
Projection)
    +  : Map[Row, ArrayBuffer[Row]] = {
    +    // TODO: Use Spark's HashMap implementation.
    +    val hashTable = scala.collection.mutable.Map[Row, ArrayBuffer[Row]]()
    +    while (iter.hasNext) {
    +      val currentRow = iter.next()
    +      val rowKey = keyGenerator(currentRow)
    +
    +      val existingMatchList = hashTable.getOrElseUpdate(rowKey, {new 
ArrayBuffer[Row]()})
    +      existingMatchList += currentRow.copy()
    +    }
    +    
    +    hashTable.toMap[Row, ArrayBuffer[Row]]
    +  }
    +  
    +  def execute() = {
    +    left.execute().zipPartitions(right.execute()) { (leftIter, rightIter) 
=>
    +      // TODO this probably can be replaced by external sort (sort merged 
join?)
    +      val leftHashTable = buildHashTable(leftIter, newProjection(leftKeys, 
left.output))
    +      val rightHashTable= buildHashTable(rightIter, 
newProjection(rightKeys, right.output))
    --- End diff --
    
    Space before =


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

Reply via email to