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



##########
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:
       So you mean use AtomicLong is sufficient and overflow check is 
redundant?  may be you are right,let me push some new code,think you 




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


Reply via email to