You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/05/12 10:59:01 UTC

[GitHub] [iotdb] MinaQin opened a new issue, #5880: Save and re-use this "Random".

MinaQin opened a new issue, #5880:
URL: https://github.com/apache/iotdb/issues/5880

   Code Path: confignode/src/main/java/org/apache/iotdb/confignode/manager/PartitionManager.java
   <img width="860" alt="image" src="https://user-images.githubusercontent.com/55030443/168055853-74a33d4b-e7a3-4bf0-a0d3-7ca161adb3b3.png">
   Creating a new Random object each time a random value is needed is inefficient and may produce numbers which are not random depending on the JDK. For better efficiency and randomness, create a single Random, then store, and reuse it.
   
   The Random() constructor tries to set the seed with a distinct value every time. However there is no guarantee that the seed will be random or even uniformly distributed. Some JDK will use the current time as seed, which makes the generated numbers not random at all.
   
   This rule finds cases where a new Random is created each time a method is invoked.


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

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] azhsmesos commented on issue #5880: Save and re-use this "Random".

Posted by GitBox <gi...@apache.org>.
azhsmesos commented on issue #5880:
URL: https://github.com/apache/iotdb/issues/5880#issuecomment-1189733941

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

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] azhsmesos commented on issue #5880: Save and re-use this "Random".

Posted by GitBox <gi...@apache.org>.
azhsmesos commented on issue #5880:
URL: https://github.com/apache/iotdb/issues/5880#issuecomment-1149563992

   My idea is to add a cache to store random. If this idea is possible, please assigned it to me


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

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org