Class RandomSamplingFacetsCollector.XORShift64Random

java.lang.Object
org.apache.lucene.facet.RandomSamplingFacetsCollector.XORShift64Random
Enclosing class:
RandomSamplingFacetsCollector

private static class RandomSamplingFacetsCollector.XORShift64Random extends Object
Faster alternative for java.util.Random, inspired by http://dmurphy747.wordpress.com/2011/03/23/xorshift-vs-random- performance-in-java/

Has a period of 2^64-1

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    XORShift64Random(long seed)
    Creates a xorshift random generator using the provided seed
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    nextInt(int n)
    Get the next random int, between 0 (inclusive) and n (exclusive)
    long
    Get the next random long value

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • x

      private long x
  • Constructor Details

    • XORShift64Random

      public XORShift64Random(long seed)
      Creates a xorshift random generator using the provided seed
  • Method Details

    • randomLong

      public long randomLong()
      Get the next random long value
    • nextInt

      public int nextInt(int n)
      Get the next random int, between 0 (inclusive) and n (exclusive)