glasser commented on a change in pull request #6226: Prohibit some Random usage
patterns
URL: https://github.com/apache/incubator-druid/pull/6226#discussion_r228640742
##########
File path:
indexing-service/src/main/java/org/apache/druid/indexing/common/task/RealtimeIndexTask.java
##########
@@ -76,34 +76,43 @@
import java.io.File;
import java.io.IOException;
import java.util.Map;
-import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ThreadLocalRandom;
public class RealtimeIndexTask extends AbstractTask
{
public static final String CTX_KEY_LOOKUP_TIER = "lookupTier";
private static final EmittingLogger log = new
EmittingLogger(RealtimeIndexTask.class);
- private static final Random random = new Random();
+
+ private static final int TASK_ID_BITS_PER_SYMBOL = 4;
+ private static final int TASK_ID_SYMBOL_MASK = (1 <<
TASK_ID_BITS_PER_SYMBOL) - 1;
+ private static final int TASK_ID_LENGTH = Integer.BYTES /
TASK_ID_BITS_PER_SYMBOL;
Review comment:
Shouldn't this be Integer.SIZE rather than Integer.BYTES? Just doing unit
analysis it seems wrong: (bytes / (bits/symbol)) = symbol * (bytes/bits) =
symbol/8. This is giving single-character IDs for me, which seems wrong.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]