Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/11130#discussion_r52838770
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/BroadcastHashJoin.scala
---
@@ -184,36 +240,106 @@ case class BroadcastHashJoin(
if (broadcastRelation.value.isInstanceOf[UniqueHashedRelation]) {
s"""
- | // generate join key
- | ${keyVal.code}
- | // find matches from HashedRelation
- | UnsafeRow $matched = $anyNull ? null:
(UnsafeRow)$relationTerm.getValue(${keyVal.value});
- | if ($matched != null) {
- | ${buildColumns.map(_.code).mkString("\n")}
- | $outputCode
- | }
- """.stripMargin
+ |// generate join key
+ |${keyEv.code}
+ |// find matches from HashedRelation
+ |UnsafeRow $matched = $anyNull ? null:
(UnsafeRow)$relationTerm.getValue(${keyEv.value});
+ |if ($matched != null) {
+ | ${buildVars.map(_.code).mkString("\n")}
+ | $outputCode
+ |}
+ """.stripMargin
+
+ } else {
+ val matches = ctx.freshName("matches")
+ val bufferType = classOf[CompactBuffer[UnsafeRow]].getName
+ val i = ctx.freshName("i")
+ val size = ctx.freshName("size")
+ s"""
+ |// generate join key
+ |${keyEv.code}
+ |// find matches from HashRelation
+ |$bufferType $matches = $anyNull ? null :
($bufferType)$relationTerm.get(${keyEv.value});
+ |if ($matches != null) {
+ | int $size = $matches.size();
+ | for (int $i = 0; $i < $size; $i++) {
+ | UnsafeRow $matched = (UnsafeRow) $matches.apply($i);
+ | ${buildVars.map(_.code).mkString("\n")}
+ | $outputCode
+ | }
+ |}
+ """.stripMargin
+ }
+ }
+
+
+ private def codegenOuter(ctx: CodegenContext, input: Seq[ExprCode]):
String = {
--- End diff --
there are lots of code duplication from codegenInner. Can we merge them?
---
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]