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

    https://github.com/apache/spark/pull/15620#discussion_r90189958
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala
 ---
    @@ -64,19 +64,72 @@ case class If(predicate: Expression, trueValue: 
Expression, falseValue: Expressi
         val trueEval = trueValue.genCode(ctx)
         val falseEval = falseValue.genCode(ctx)
     
    -    ev.copy(code = s"""
    -      ${condEval.code}
    -      boolean ${ev.isNull} = false;
    -      ${ctx.javaType(dataType)} ${ev.value} = 
${ctx.defaultValue(dataType)};
    -      if (!${condEval.isNull} && ${condEval.value}) {
    -        ${trueEval.code}
    -        ${ev.isNull} = ${trueEval.isNull};
    -        ${ev.value} = ${trueEval.value};
    -      } else {
    -        ${falseEval.code}
    -        ${ev.isNull} = ${falseEval.isNull};
    -        ${ev.value} = ${falseEval.value};
    -      }""")
    +    // place generated code of condition, true value and false value in 
separate methods if
    +    // their code combined is large
    +    val combinedLength = condEval.code.length + trueEval.code.length + 
falseEval.code.length
    +    val generatedCode = if (combinedLength > 1024 &&
    --- End diff --
    
    I used the same limit as in following change:
    
https://github.com/apache/spark/pull/14692/files#diff-8bcc5aea39c73d4bf38aef6f6951d42cL595
    
    which is based on some benchmarks. In addition, for JIT to do its 
optimisations, I think the limit is 8k.


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

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

Reply via email to