/** * Constructor with the given sample size and seed. * * @param sampleSize * The preferred sample size. If the number of hits is greater than * the size, sampling will be done using a sample ratio of sampling * size / totalN. For example: 1000 hits, sample size = 10 results in * samplingRatio of 0.01. If the number of hits is lower, no sampling * is done at all * @param seed * The random seed. If {@code 0} then a seed will be chosen for you. */ public RandomSamplingFacetsCollector(int sampleSize, long seed) { super(false); this.sampleSize = sampleSize; this.random = new XORShift64Random(seed); this.sampledDocs = null; }
/** * Constructor with the given sample size and seed. * * @param sampleSize * The preferred sample size. If the number of hits is greater than * the size, sampling will be done using a sample ratio of sampling * size / totalN. For example: 1000 hits, sample size = 10 results in * samplingRatio of 0.01. If the number of hits is lower, no sampling * is done at all * @param seed * The random seed. If {@code 0} then a seed will be chosen for you. */ public RandomSamplingFacetsCollector(int sampleSize, long seed) { super(false); this.sampleSize = sampleSize; this.random = new XORShift64Random(seed); this.sampledDocs = null; }
/** Get the next random int, between 0 (inclusive) and n (exclusive) */ public int nextInt(int n) { int res = (int) (randomLong() % n); return (res < 0) ? -res : res; }
/** Get the next random int, between 0 (inclusive) and n (exclusive) */ public int nextInt(int n) { int res = (int) (randomLong() % n); return (res < 0) ? -res : res; }