public final class MurmurHash3Adaptor extends Object
Modifier and Type | Method and Description |
---|---|
static double |
asDouble(long[] hash)
Returns a uniform random double with a minimum inclusive value of zero and a maximum exclusive
value of 1.0.
|
static int |
asInt(byte[] data,
int n)
Returns a deterministic uniform random integer between zero (inclusive) and
n (exclusive) given the input data.
|
static int |
asInt(double datum,
int n)
Returns a deterministic uniform random integer between zero (inclusive) and
n (exclusive) given the input double.
|
static int |
asInt(int[] data,
int n)
Returns a deterministic uniform random integer between zero (inclusive) and
n (exclusive) given the input data.
|
static int |
asInt(long[] data,
int n)
Returns a deterministic uniform random integer between zero (inclusive) and
n (exclusive) given the input data.
|
static int |
asInt(long datum,
int n)
Returns a deterministic uniform random integer between zero (inclusive) and
n (exclusive) given the input datum.
|
static int |
asInt(String datum,
int n)
Returns a deterministic uniform random integer between zero (inclusive) and
n (exclusive) given the input datum.
|
static byte[] |
hashToBytes(byte[] data,
long seed)
Hash a byte[] and long seed.
|
static byte[] |
hashToBytes(char[] data,
long seed)
Hash a char[] and long seed.
|
static byte[] |
hashToBytes(double datum,
long seed)
Hash a double and long seed.
|
static byte[] |
hashToBytes(int[] data,
long seed)
Hash an int[] and long seed.
|
static byte[] |
hashToBytes(long[] data,
long seed)
Hash a long[] and long seed.
|
static byte[] |
hashToBytes(long datum,
long seed)
Hash a long and long seed.
|
static byte[] |
hashToBytes(String datum,
long seed)
Hash a String and long seed.
|
static long[] |
hashToLongs(byte[] data,
long seed)
Hash a byte[] and long seed.
|
static long[] |
hashToLongs(char[] data,
long seed)
Hash a char[] and long seed.
|
static long[] |
hashToLongs(double datum,
long seed)
Hash a double and long seed.
|
static long[] |
hashToLongs(int[] data,
long seed)
Hash a int[] and long seed.
|
static long[] |
hashToLongs(long[] data,
long seed)
Hash a long[] and long seed.
|
static long[] |
hashToLongs(long datum,
long seed)
Hash a long and long seed.
|
static long[] |
hashToLongs(String datum,
long seed)
Hash a String and long seed.
|
static int |
modulo(long[] hash,
int divisor)
Returns the remainder from the modulo division of the 128-bit output of the murmurHash3 by the
divisor.
|
static int |
modulo(long h0,
long h1,
int divisor)
Returns the remainder from the modulo division of the 128-bit output of the murmurHash3 by the
divisor.
|
public static byte[] hashToBytes(long datum, long seed)
datum
- the input long valueseed
- A long valued seed.public static byte[] hashToBytes(long[] data, long seed)
data
- the input long arrayseed
- A long valued seed.public static byte[] hashToBytes(int[] data, long seed)
data
- the input int arrayseed
- A long valued seed.public static byte[] hashToBytes(char[] data, long seed)
data
- the input char arrayseed
- A long valued seed.public static byte[] hashToBytes(byte[] data, long seed)
data
- the input byte arrayseed
- A long valued seed.public static byte[] hashToBytes(double datum, long seed)
datum
- the input doubleseed
- A long valued seed.public static byte[] hashToBytes(String datum, long seed)
datum
- the input Stringseed
- A long valued seed.public static long[] hashToLongs(long datum, long seed)
datum
- the input longseed
- A long valued seed.public static long[] hashToLongs(long[] data, long seed)
data
- the input long array.seed
- A long valued seed.public static long[] hashToLongs(int[] data, long seed)
data
- the input int array.seed
- A long valued seed.public static long[] hashToLongs(char[] data, long seed)
data
- the input char array.seed
- A long valued seed.public static long[] hashToLongs(byte[] data, long seed)
data
- the input byte array.seed
- A long valued seed.public static long[] hashToLongs(double datum, long seed)
datum
- the input double.seed
- A long valued seed.public static long[] hashToLongs(String datum, long seed)
datum
- the input String.seed
- A long valued seed.public static int asInt(long[] data, int n)
data
- the input long array.n
- The upper exclusive bound of the integers produced. Must be > 1.public static int asInt(int[] data, int n)
data
- the input int array.n
- The upper exclusive bound of the integers produced. Must be > 1.public static int asInt(byte[] data, int n)
data
- the input byte array.n
- The upper exclusive bound of the integers produced. Must be > 1.public static int asInt(long datum, int n)
datum
- the input longn
- The upper exclusive bound of the integers produced. Must be > 1.public static int asInt(double datum, int n)
datum
- the given double.n
- The upper exclusive bound of the integers produced. Must be > 1.public static int asInt(String datum, int n)
datum
- the given String.n
- The upper exclusive bound of the integers produced. Must be > 1.public static double asDouble(long[] hash)
The double values produced are only as random as the MurmurHash3 algorithm, which may be adequate for many applications. However, if you are looking for high guarantees of randomness you should turn to more sophisticated random generators such as Mersenne Twister or Well algorithms.
hash
- The output of the MurmurHash3.public static int modulo(long h0, long h1, int divisor)
h0
- The lower 64-bits of the 128-bit MurmurHash3 hash.h1
- The upper 64-bits of the 128-bit MurmurHash3 hash.divisor
- Must be positive and greater than zero.public static int modulo(long[] hash, int divisor)
hash
- The size 2 long array from the MurmurHash3.divisor
- Must be positive and greater than zero.Copyright © 2015–2024 The Apache Software Foundation. All rights reserved.