yimeisun commented on a change in pull request #15354:
URL: https://github.com/apache/flink/pull/15354#discussion_r602848018
##########
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:
I don't agree with you for some reasons below:
1) extra function call is slow several times than atomic increment, not
lightweight;
2) generate duplicated class name will also throw exception when compile;
3) For Long.MAX_VALUE, if service serves 500 sqls per second and 3
expression reducers per sql, it will take 197688872 years until overflow; //
Long.MAX_VALUE/((long)12 * 30 * 24 * 3600 * 500 * 3)
--
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]