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

[GitHub] spark pull request #19082: [SPARK-21870][SQL] Split aggregation code into sm...

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

    https://github.com/apache/spark/pull/19082#discussion_r155999993
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -1070,6 +1071,24 @@ class CodegenContext {
       }
     }
     
    +object CodegenContext {
    +
    +  private val javaKeywords = Set(
    +    "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const",
    +    "continue", "default", "do", "double", "else", "extends", "false", "final", "finally", "float",
    +    "for", "goto", "if", "implements", "import", "instanceof", "int", "interface", "long", "native",
    +    "new", "null", "package", "private", "protected", "public", "return", "short", "static",
    +    "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true",
    +    "try", "void", "volatile", "while"
    +  )
    +
    +  def isJavaIdentifier(str: String): Boolean = str match {
    +    case null | "" => false
    +    case _ => !javaKeywords.contains(str) && isJavaIdentifierStart(str.charAt(0)) &&
    +      (1 until str.length).forall(i => isJavaIdentifierPart(str.charAt(i)))
    +  }
    --- End diff --
    
    ```Scala
      /**
       * Returns true if the given `str` is a valid java identifier.
       */
      def isJavaIdentifier(str: String): Boolean = str match {
        case null | "" =>
          false
        case _ =>
          !javaKeywords.contains(str) && isJavaIdentifierStart(str.charAt(0)) &&
            (1 until str.length).forall(i => isJavaIdentifierPart(str.charAt(i)))
      }
    ```


---

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