You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by viirya <gi...@git.apache.org> on 2017/12/13 05:18:08 UTC

[GitHub] spark pull request #19778: [SPARK-22550][SQL] Fix 64KB JVM bytecode limit pr...

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

    https://github.com/apache/spark/pull/19778#discussion_r156566161
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala ---
    @@ -224,22 +224,52 @@ case class Elt(children: Seq[Expression])
       override protected def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
         val index = indexExpr.genCode(ctx)
         val strings = stringExprs.map(_.genCode(ctx))
    +    val indexVal = ctx.freshName("index")
    +    val stringVal = ctx.freshName("stringVal")
         val assignStringValue = strings.zipWithIndex.map { case (eval, index) =>
           s"""
             case ${index + 1}:
    -          ${ev.value} = ${eval.isNull} ? null : ${eval.value};
    +          ${eval.code}
    +          $stringVal = ${eval.isNull} ? null : ${eval.value};
               break;
           """
    -    }.mkString("\n")
    -    val indexVal = ctx.freshName("index")
    -    val stringArray = ctx.freshName("strings");
    +    }
     
    -    ev.copy(index.code + "\n" + strings.map(_.code).mkString("\n") + s"""
    -      final int $indexVal = ${index.value};
    -      UTF8String ${ev.value} = null;
    -      switch ($indexVal) {
    -        $assignStringValue
    +    val cases = ctx.buildCodeBlocks(assignStringValue)
    +    val codes = if (cases.length == 1) {
    +      s"""
    +        UTF8String $stringVal = null;
    +        switch ($indexVal) {
    +          ${cases.head}
    +        }
    +       """
    +    } else {
    +      var prevFunc = "null"
    +      for (c <- cases.reverse) {
    +        val funcName = ctx.freshName("eltFunc")
    +        val funcBody = s"""
    +         private UTF8String $funcName(InternalRow ${ctx.INPUT_ROW}, int $indexVal) {
    --- End diff --
    
    Looks like this splitting doesn't prevent the case in wholestage codegen?


---

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