kiszk commented on a change in pull request #23171: [SPARK-26205][SQL] Optimize 
In for bytes, shorts, ints
URL: https://github.com/apache/spark/pull/23171#discussion_r242798319
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
 ##########
 @@ -335,6 +343,41 @@ case class In(value: Expression, list: Seq[Expression]) 
extends Predicate {
        """.stripMargin)
   }
 
+  private def genCodeWithSwitch(ctx: CodegenContext, ev: ExprCode): ExprCode = 
{
+    val (nullLiterals, nonNullLiterals) = list.partition {
+      case Literal(null, _) => true
+      case _ => false
+    }
+    val listGen = nonNullLiterals.map(_.genCode(ctx))
+    val valueGen = value.genCode(ctx)
+
+    val caseBranches = listGen.map(literal =>
+      s"""
+         |case ${literal.value}:
+         |  ${ev.value} = true;
+         |  break;
+       """.stripMargin)
+
+    ev.copy(code =
+      code"""
+         |${valueGen.code}
+         |${CodeGenerator.JAVA_BOOLEAN} ${ev.isNull} = ${valueGen.isNull};
+         |${CodeGenerator.JAVA_BOOLEAN} ${ev.value} = false;
+         |if (!${valueGen.isNull}) {
+         |  switch (${valueGen.value}) {
+         |    ${caseBranches.mkString("")}
 
 Review comment:
   Could you please add test cases that could cause more than 64KB Java 
bytecode size in one switch statement?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to