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

    https://github.com/apache/spark/pull/15480#discussion_r83582242
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateOrdering.scala
 ---
    @@ -118,7 +118,45 @@ object GenerateOrdering extends 
CodeGenerator[Seq[SortOrder], Ordering[InternalR
               }
           """
         }.mkString("\n")
    -    comparisons
    +
    +    /*
    --- End diff --
    
    @lw-lin , good points.
    For the second issue, can we use the string length as a proxy?
    For the first issue, how about the following approach? In advance, I am 
sorry that I have not compiled it myself.
    
    ```java
    // CodeGenerator.scalar
    def splitExpressions(expressions: Seq[String], funcName: String, arguments: 
Seq[(String, String), returns: (String, String] =("void", "")): String = {
      ..
      val code = s"""
        |private $(returns._1) $name(${arguments.map { case (t, name) => s"$t 
$name" }.mkString(", ")}) {
        |  $body
        |  ${returns._2)
        |}
      """.stripMargin
    ...
    }
    ```
    
    ```java
    // GenerateOrdering.scala 
      val groupedOrderingItr = ordering.grouped(numberOfComparisonsThreshold)
      // var groupedOrderingLength = 0
      val functions = ctx.splitExpressions {
        ..
      }
      val comp = freshName("comp")
      functions.zipWithIndex.map { case(func , i) =>
        val name = s"${comp}_$i"
        s"""
          |int $name = $func(a, b);
          |if ($name != 0) {
          |  return $name;
          |}
        """.stripMargin
      }.mkString
    ```


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