Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/395#discussion_r11649983
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/joins.scala ---
@@ -165,36 +165,64 @@ case class BroadcastNestedLoopJoin(
def execute() = {
val broadcastedRelation =
sc.broadcast(broadcast.execute().map(_.copy()).collect().toIndexedSeq)
- val streamedPlusMatches = streamed.execute().mapPartitions {
streamedIter =>
- val matchedRows = new ArrayBuffer[Row]
- // TODO: Use Spark's BitSet.
- val includedBroadcastTuples = new
BitSet(broadcastedRelation.value.size)
- val joinedRow = new JoinedRow
-
- streamedIter.foreach { streamedRow =>
- var i = 0
- var matched = false
-
- while (i < broadcastedRelation.value.size) {
- // TODO: One bitset per partition instead of per row.
- val broadcastedRow = broadcastedRelation.value(i)
- if (boundCondition(joinedRow(streamedRow, broadcastedRow))) {
- matchedRows += buildRow(streamedRow ++ broadcastedRow)
- matched = true
- includedBroadcastTuples += i
- }
- i += 1
+ val streamedPlusMatches = joinType match {
+ case LeftSemi =>
+ streamed.execute().mapPartitions {
+ streamedIter =>
+ val matchedRows = new ArrayBuffer[Row]
+ val joinedRow = new JoinedRow
+
+ streamedIter.foreach {
+ streamedRow =>
+ var i = 0
+ var matched = false
+
+ while (i < broadcastedRelation.value.size && !matched) {
+ // TODO: One bitset per partition instead of per row.
+ val broadcastedRow = broadcastedRelation.value(i)
+ if (boundCondition(joinedRow(streamedRow,
broadcastedRow))) {
+ matchedRows += buildRow(streamedRow)
--- End diff --
There is no need to call `buildRow` here, as you can just use streamedRow.
---
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.
---