spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiszk <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-15285][SQL] Generated SpecificSafeProje...
Date Mon, 23 May 2016 02:01:36 GMT
Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13243#discussion_r64162262
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
---
    @@ -232,27 +232,55 @@ case class NewInstance(
     
       override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
         val javaType = ctx.javaType(dataType)
    -    val argGen = arguments.map(_.genCode(ctx))
    -    val argString = argGen.map(_.value).mkString(", ")
    +    val argIsNulls = ctx.freshName("argIsNulls")
    +    ctx.addMutableState("boolean[]", argIsNulls, "")
    +    val argTypes = arguments.map(e => ctx.javaType(e.dataType))
    +    val argValues = arguments.zipWithIndex.map { case (e, i) =>
    +      val argValue = ctx.freshName("argValue")
    +      ctx.addMutableState(argTypes(i), argValue, "")
    +      argValue
    +    }
    +
    +    val argCodes = arguments.zipWithIndex.map { case (e, i) =>
    +      val expr = e.genCode(ctx)
    +      expr.code + s"""
    +       $argIsNulls[$i] = ${expr.isNull};
    +       ${argValues(i)} = ${expr.value};
    +     """
    +    }
    +    val argCode = ctx.splitExpressions(ctx.INPUT_ROW, argCodes)
     
         val outer = outerPointer.map(func => Literal.fromObject(func()).genCode(ctx))
     
         var isNull = ev.isNull
         val setIsNull = if (propagateNull && arguments.nonEmpty) {
    -      s"final boolean $isNull = ${argGen.map(_.isNull).mkString(" || ")};"
    +      if (arguments.length <= 10) {
    --- End diff --
    
    I have no particular reason for pick ```10```. ```100``` seems to be too long.
    Do you have any suggestion to pick the value?


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


Mime
View raw message