yimeisun commented on a change in pull request #15354:
URL: https://github.com/apache/flink/pull/15354#discussion_r601421952



##########
File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/codegen/CodeGenUtils.scala
##########
@@ -116,15 +116,28 @@ object CodeGenUtils {
 
   // 
----------------------------------------------------------------------------------------
 
-  private val nameCounter = new AtomicInteger
+  private val nameCounter = new AtomicLong
+
+  private def newNameSuffixNumber(): Long = {
+    val newNameCounter = nameCounter.getAndIncrement
+    if (newNameCounter < 0) {
+      // should we throw a Exception here in case duplicate suffix number ?
+      synchronized {
+        nameCounter.set(0)
+      }
+      nameCounter.getAndIncrement
+    } else {
+      newNameCounter
+    }
+  }
 
   def newName(name: String): String = {
-    s"$name$$${nameCounter.getAndIncrement}"
+    s"$name$$${newNameSuffixNumber()}"

Review comment:
       In online service performance is important, extra function call will 
cause performance degradation. Check less than zero is  not necessary here. On 
the other side, newName() should return a unique class name here.




-- 
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:
[email protected]


Reply via email to