mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-05 20:48:22 +00:00
Mvel Script: add more random options, and optimize random, closes #759.
This commit is contained in:
parent
016e5bce04
commit
353d2cb21f
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package org.elasticsearch.common.math;
|
package org.elasticsearch.common.math;
|
||||||
|
|
||||||
|
import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
@ -427,7 +429,31 @@ public class UnboxedMathUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double random() {
|
public static double random() {
|
||||||
return Math.random();
|
return ThreadLocalRandom.current().nextDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double randomDouble() {
|
||||||
|
return ThreadLocalRandom.current().nextDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double randomFloat() {
|
||||||
|
return ThreadLocalRandom.current().nextFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double randomInt() {
|
||||||
|
return ThreadLocalRandom.current().nextInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double randomInt(Integer i) {
|
||||||
|
return ThreadLocalRandom.current().nextInt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double randomLong() {
|
||||||
|
return ThreadLocalRandom.current().nextLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double randomLong(Long l) {
|
||||||
|
return ThreadLocalRandom.current().nextLong(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int abs(Integer a) {
|
public static int abs(Integer a) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user