You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by davies <gi...@git.apache.org> on 2016/03/15 22:18:40 UTC

[GitHub] spark pull request: generate semi join

GitHub user davies opened a pull request:

    https://github.com/apache/spark/pull/11742

    generate semi join

    ## What changes were proposed in this pull request?
    
    This PR brings codegen support for broadcast left-semi join.
    
    ## How was this patch tested?
    
    Existing tests.
    
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/davies/spark gen_semi

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/11742.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #11742
    
----
commit 32983190adb26bab1d1ff865f71b638374c43600
Author: Davies Liu <da...@databricks.com>
Date:   2016-03-15T20:24:26Z

    generate semi join

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11742#issuecomment-197063207
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/53223/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: generate semi join

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11742#issuecomment-197025538
  
    **[Test build #53223 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/53223/consoleFull)** for PR 11742 at commit [`3298319`](https://github.com/apache/spark/commit/32983190adb26bab1d1ff865f71b638374c43600).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11742#issuecomment-197062901
  
    **[Test build #53223 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/53223/consoleFull)** for PR 11742 at commit [`3298319`](https://github.com/apache/spark/commit/32983190adb26bab1d1ff865f71b638374c43600).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11742#issuecomment-197157622
  
    **[Test build #53278 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/53278/consoleFull)** for PR 11742 at commit [`f1ca6f2`](https://github.com/apache/spark/commit/f1ca6f250d85ee9ba9fcdbb308486588a527eb87).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11742#issuecomment-197068054
  
    **[Test build #53226 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/53226/consoleFull)** for PR 11742 at commit [`7471741`](https://github.com/apache/spark/commit/74717411274e6810f95be7e60c0406ac04a2e3f4).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by nongli <gi...@git.apache.org>.
Github user nongli commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11742#discussion_r56277373
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/joins/BroadcastHashJoin.scala ---
    @@ -322,4 +327,70 @@ case class BroadcastHashJoin(
            """.stripMargin
         }
       }
    +
    +  /**
    +   * Generates the code for left semi join.
    +   */
    +  private def codegenSemi(ctx: CodegenContext, input: Seq[ExprCode]): String = {
    +    val (broadcastRelation, relationTerm) = prepareBroadcast(ctx)
    +    val (keyEv, anyNull) = genStreamSideJoinKey(ctx, input)
    +    val matched = ctx.freshName("matched")
    +    val buildVars = genBuildSideVars(ctx, matched)
    +    val numOutput = metricTerm(ctx, "numOutputRows")
    +
    +    val checkCondition = if (condition.isDefined) {
    +      val expr = condition.get
    +      // evaluate the variables from build side that used by condition
    +      val eval = evaluateRequiredVariables(buildPlan.output, buildVars, expr.references)
    +      // filter the output via condition
    +      ctx.currentVars = input ++ buildVars
    +      val ev = BindReferences.bindReference(expr, streamedPlan.output ++ buildPlan.output).gen(ctx)
    +      s"""
    +         |$eval
    +         |${ev.code}
    +         |if (${ev.isNull} || !${ev.value}) continue;
    +       """.stripMargin
    +    } else {
    +      ""
    +    }
    +
    +    if (broadcastRelation.value.isInstanceOf[UniqueHashedRelation]) {
    +      s"""
    +         |// generate join key for stream side
    +         |${keyEv.code}
    +         |// find matches from HashedRelation
    +         |UnsafeRow $matched = $anyNull ? null: (UnsafeRow)$relationTerm.getValue(${keyEv.value});
    +         |if ($matched == null) continue;
    +         |$checkCondition
    +         |$numOutput.add(1);
    +         |${consume(ctx, input)}
    +       """.stripMargin
    +
    +    } else {
    +      val matches = ctx.freshName("matches")
    +      val bufferType = classOf[CompactBuffer[UnsafeRow]].getName
    +      val i = ctx.freshName("i")
    +      val size = ctx.freshName("size")
    +      val found = ctx.freshName("found")
    +      s"""
    +         |// generate join key for stream side
    +         |${keyEv.code}
    +         |// find matches from HashRelation
    +         |$bufferType $matches = $anyNull ? null : ($bufferType)$relationTerm.get(${keyEv.value});
    +         |if ($matches == null) continue;
    +         |int $size = $matches.size();
    +         |boolean $found = false;
    +         |for (int $i = 0; $i < $size; $i++) {
    +         |  UnsafeRow $matched = (UnsafeRow) $matches.apply($i);
    +         |  $checkCondition
    +         |  $found = true;
    +         |  break;
    +         |}
    +         |if (!$found) continue;
    +         |$numOutput.add(1);
    +         |${consume(ctx, input)}
    +       """.stripMargin
    +
    --- End diff --
    
    and 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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11742#issuecomment-197192360
  
    **[Test build #53278 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/53278/consoleFull)** for PR 11742 at commit [`f1ca6f2`](https://github.com/apache/spark/commit/f1ca6f250d85ee9ba9fcdbb308486588a527eb87).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11742#issuecomment-197063206
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11742#issuecomment-197068316
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on the pull request:

    https://github.com/apache/spark/pull/11742#issuecomment-197041765
  
    cc @nongli 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11742#issuecomment-197192660
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/53278/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by nongli <gi...@git.apache.org>.
Github user nongli commented on the pull request:

    https://github.com/apache/spark/pull/11742#issuecomment-197133107
  
    LGTM


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/11742


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by nongli <gi...@git.apache.org>.
Github user nongli commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11742#discussion_r56277324
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/joins/BroadcastHashJoin.scala ---
    @@ -322,4 +327,70 @@ case class BroadcastHashJoin(
            """.stripMargin
         }
       }
    +
    +  /**
    +   * Generates the code for left semi join.
    +   */
    +  private def codegenSemi(ctx: CodegenContext, input: Seq[ExprCode]): String = {
    +    val (broadcastRelation, relationTerm) = prepareBroadcast(ctx)
    +    val (keyEv, anyNull) = genStreamSideJoinKey(ctx, input)
    +    val matched = ctx.freshName("matched")
    +    val buildVars = genBuildSideVars(ctx, matched)
    +    val numOutput = metricTerm(ctx, "numOutputRows")
    +
    +    val checkCondition = if (condition.isDefined) {
    +      val expr = condition.get
    +      // evaluate the variables from build side that used by condition
    +      val eval = evaluateRequiredVariables(buildPlan.output, buildVars, expr.references)
    +      // filter the output via condition
    +      ctx.currentVars = input ++ buildVars
    +      val ev = BindReferences.bindReference(expr, streamedPlan.output ++ buildPlan.output).gen(ctx)
    +      s"""
    +         |$eval
    +         |${ev.code}
    +         |if (${ev.isNull} || !${ev.value}) continue;
    +       """.stripMargin
    +    } else {
    +      ""
    +    }
    +
    +    if (broadcastRelation.value.isInstanceOf[UniqueHashedRelation]) {
    +      s"""
    +         |// generate join key for stream side
    +         |${keyEv.code}
    +         |// find matches from HashedRelation
    +         |UnsafeRow $matched = $anyNull ? null: (UnsafeRow)$relationTerm.getValue(${keyEv.value});
    +         |if ($matched == null) continue;
    +         |$checkCondition
    +         |$numOutput.add(1);
    +         |${consume(ctx, input)}
    +       """.stripMargin
    +
    --- End diff --
    
    extra new line


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11742#issuecomment-197192659
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: generate semi join

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11742#issuecomment-197035834
  
    **[Test build #53226 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/53226/consoleFull)** for PR 11742 at commit [`7471741`](https://github.com/apache/spark/commit/74717411274e6810f95be7e60c0406ac04a2e3f4).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13917] [SQL] generate broadcast semi jo...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11742#issuecomment-197068318
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/53226/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org