JingsongLi commented on a change in pull request #7906: 
[FLINK-11830][table-planner-blink] Introduce CodeGeneratorContext to maintain 
reusable statements
URL: https://github.com/apache/flink/pull/7906#discussion_r262782535
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/codegen/CodeGenUtils.scala
 ##########
 @@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.codegen
+
+import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo._
+import org.apache.flink.api.common.typeinfo.TypeInformation
+import org.apache.flink.table.`type`._
+import org.apache.flink.table.dataformat._
+import org.apache.flink.table.typeutils.TypeCheckUtils
+
+import java.lang.reflect.Method
+import java.lang.{Boolean => JBoolean, Byte => JByte, Character => JChar, 
Double => JDouble, Float => JFloat, Integer => JInt, Long => JLong, Short => 
JShort}
+import java.util.concurrent.atomic.AtomicInteger
+
+object CodeGenUtils {
+
+  // ------------------------------- DEFAULT TERMS 
------------------------------------------
+
+  val DEFAULT_TIMEZONE_TERM = "timeZone"
+
+  // -------------------------- CANONICAL CLASS NAMES 
---------------------------------------
+
+  val BINARY_ROW: String = className[BinaryRow]
+  val BINARY_STRING: String = className[BinaryString]
+  val BASE_ROW: String = className[BaseRow]
+  val GENERIC_ROW: String = className[GenericRow]
+
+  // 
----------------------------------------------------------------------------------------
+
+  private val nameCounter = new AtomicInteger
+
+  def newName(name: String): String = {
+    s"$name$$${nameCounter.getAndIncrement}"
+  }
+
+  def newNames(names: String*): Seq[String] = {
+    require(names.toSet.size == names.length, "Duplicated names")
+    val newId = nameCounter.getAndIncrement
+    names.map(name => s"$name$$$newId")
+  }
+
+  /**
+    * Retrieve the canonical name of a class type.
+    */
+  def className[T](implicit m: Manifest[T]): String = 
m.runtimeClass.getCanonicalName
+
+  def needCopyForType(t: InternalType): Boolean = t match {
+    case InternalTypes.STRING => true
+    case _: ArrayType => true
+    case _: MapType => true
+    case _: RowType => true
+    case _: GenericType[_] => true
+    case _ => false
+  }
+
+  def needCloneRefForType(t: InternalType): Boolean = t match {
 
 Review comment:
   This method is useless.

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


With regards,
Apache Git Services

Reply via email to