Package akka.routing
Class MurmurHash$
- java.lang.Object
-
- akka.routing.MurmurHash$
-
public class MurmurHash$ extends java.lang.ObjectAn object designed to generate well-distributed non-cryptographic hashes. It is designed to hash a collection of integers; along with the integers to hash, it generates two magic streams of integers to increase the distribution of repetitive input sequences. Thus, three methods need to be called at each step (to start and to incorporate a new integer) to update the values. Only one method needs to be called to finalize the hash.
-
-
Field Summary
Fields Modifier and Type Field Description static MurmurHash$MODULE$Static reference to the singleton instance of this Scala object.
-
Constructor Summary
Constructors Constructor Description MurmurHash$()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> intarrayHash(java.lang.Object a)Compute a high-quality hash of an arrayintextendHash(int hash, int value, int magicA, int magicB)Incorporates a new value into an existing hash.intfinalizeHash(int hash)Once all hashes have been incorporated, this performs a final mixingintnextMagicA(int magicA)Given a magic integer from the first stream, compute the nextintnextMagicB(int magicB)Given a magic integer from the second stream, compute the nextintstartHash(int seed)Begin a new hash with a seed value.intstartMagicA()The initial magic integers in the first stream.intstartMagicB()The initial magic integer in the second stream.intstringHash(java.lang.String s)Compute a high-quality hash of a string<T> intsymmetricHash(scala.collection.IterableOnce<T> xs, int seed)Compute a hash that is symmetric in its arguments--that is, where the order of appearance of elements does not matter.
-
-
-
Field Detail
-
MODULE$
public static final MurmurHash$ MODULE$
Static reference to the singleton instance of this Scala object.
-
-
Method Detail
-
startHash
public int startHash(int seed)
Begin a new hash with a seed value.
-
startMagicA
public int startMagicA()
The initial magic integers in the first stream.
-
startMagicB
public int startMagicB()
The initial magic integer in the second stream.
-
extendHash
public int extendHash(int hash, int value, int magicA, int magicB)Incorporates a new value into an existing hash.- Parameters:
hash- the prior hash valuevalue- the new value to incorporatemagicA- a magic integer from the streammagicB- a magic integer from a different stream- Returns:
- the updated hash value
-
nextMagicA
public int nextMagicA(int magicA)
Given a magic integer from the first stream, compute the next
-
nextMagicB
public int nextMagicB(int magicB)
Given a magic integer from the second stream, compute the next
-
finalizeHash
public int finalizeHash(int hash)
Once all hashes have been incorporated, this performs a final mixing
-
arrayHash
public <T> int arrayHash(java.lang.Object a)
Compute a high-quality hash of an array
-
stringHash
public int stringHash(java.lang.String s)
Compute a high-quality hash of a string
-
symmetricHash
public <T> int symmetricHash(scala.collection.IterableOnce<T> xs, int seed)Compute a hash that is symmetric in its arguments--that is, where the order of appearance of elements does not matter. This is useful for hashing sets, for example.
-
-