Package org.apache.flink.util
Class XORShiftRandom
- java.lang.Object
-
- java.util.Random
-
- org.apache.flink.util.XORShiftRandom
-
- All Implemented Interfaces:
Serializable
@Public public class XORShiftRandom extends Random
Implement a random number generator based on the XORShift algorithm discovered by George Marsaglia. This RNG is observed 4.5 times faster thanRandom
in benchmark, with the cost that abandon thread-safety. So it's recommended to create a newXORShiftRandom
for each thread.- See Also:
- XORShift Algorithm Paper, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description XORShiftRandom()
XORShiftRandom(long input)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
next(int bits)
All other methods like nextInt()/nextDouble()... depends on this, so we just need to overwrite this.
-