MurmurHash3

scala.util.hashing.MurmurHash3$
object MurmurHash3

An implementation of Austin Appleby's MurmurHash 3 algorithm (MurmurHash3_x86_32). This object contains methods that hash values of various types as well as means to construct Hashing objects.

This algorithm is designed to generate well-distributed non-cryptographic hashes. It is designed to hash data in 32 bit chunks (ints).

The mix method needs to be called at each step to update the intermediate hash value. For the last chunk to incorporate into the hash mixLast may be used instead, which is slightly faster. Finally finalizeHash needs to be called to compute the final hash value.

This is based on the earlier MurmurHash3 code by Rex Kerr, but the MurmurHash3 algorithm was since changed by its creator Austin Appleby to remedy some weaknesses and improve performance. This represents the latest and supposedly final version of the algorithm (revision 136). Even so, test the generated hashes in between Scala versions, even for point releases, as fast, non-cryptographic hashing algorithms evolve rapidly.

Attributes

See also
Source
MurmurHash3.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

class ArrayHashing[T] extends Hashing[Array[T]]

Attributes

Source
MurmurHash3.scala
Supertypes
trait Hashing[Array[T]]
trait Serializable
class Object
trait Matchable
class Any

Value members

Concrete methods

def arrayHash[T](a: Array[T]): Int

Attributes

Source
MurmurHash3.scala

Attributes

Source
MurmurHash3.scala
def bytesHash(data: Array[Byte]): Int

Attributes

Source
MurmurHash3.scala

Attributes

Source
MurmurHash3.scala
def mapHash(xs: Map[_, _]): Int

Attributes

Source
MurmurHash3.scala

Attributes

Source
MurmurHash3.scala

Attributes

Source
MurmurHash3.scala
def rangeHash(start: Int, step: Int, last: Int): Int

Attributes

Source
MurmurHash3.scala
def seqHash(xs: Seq[_]): Int

To offer some potential for optimization.

To offer some potential for optimization.

Attributes

Source
MurmurHash3.scala
def setHash(xs: Set[_]): Int

Attributes

Source
MurmurHash3.scala
def stringHash(x: String): Int

Attributes

Source
MurmurHash3.scala

Attributes

Source
MurmurHash3.scala

Attributes

Source
MurmurHash3.scala

Inherited methods

final def arrayHash[T](a: Array[T], seed: Int): Int

Compute the hash of an array.

Compute the hash of an array. Potential range hashes are recognized to produce a hash that is compatible with rangeHash.

Attributes

Inherited from:
MurmurHash3 (hidden)
Source
MurmurHash3.scala
final def bytesHash(data: Array[Byte], seed: Int): Int

Compute the hash of a byte array.

Compute the hash of a byte array. Faster than arrayHash, because it hashes 4 bytes at once. Note that the result is not compatible with arrayHash!

Attributes

Inherited from:
MurmurHash3 (hidden)
Source
MurmurHash3.scala
final def finalizeHash(hash: Int, length: Int): Int

Finalize a hash to incorporate the length and make sure all bits avalanche.

Finalize a hash to incorporate the length and make sure all bits avalanche.

Attributes

Inherited from:
MurmurHash3 (hidden)
Source
MurmurHash3.scala
final def indexedSeqHash(a: IndexedSeq[Any], seed: Int): Int

Compute the hash of an IndexedSeq.

Compute the hash of an IndexedSeq. Potential range hashes are recognized to produce a hash that is compatible with rangeHash.

Attributes

Inherited from:
MurmurHash3 (hidden)
Source
MurmurHash3.scala
final def listHash(xs: List[_], seed: Int): Int

Compute the hash of a List.

Compute the hash of a List. Potential range hashes are recognized to produce a hash that is compatible with rangeHash.

Attributes

Inherited from:
MurmurHash3 (hidden)
Source
MurmurHash3.scala
final def mix(hash: Int, data: Int): Int

Mix in a block of data into an intermediate hash value.

Mix in a block of data into an intermediate hash value.

Attributes

Inherited from:
MurmurHash3 (hidden)
Source
MurmurHash3.scala
final def mixLast(hash: Int, data: Int): Int

May optionally be used as the last mixing step.

May optionally be used as the last mixing step. Is a little bit faster than mix, as it does no further mixing of the resulting hash. For the last element this is not necessary as the hash is thoroughly mixed during finalization anyway.

Attributes

Inherited from:
MurmurHash3 (hidden)
Source
MurmurHash3.scala
final def orderedHash(xs: IterableOnce[Any], seed: Int): Int

Compute a hash that depends on the order of its arguments.

Compute a hash that depends on the order of its arguments. Potential range hashes are recognized to produce a hash that is compatible with rangeHash.

Attributes

Inherited from:
MurmurHash3 (hidden)
Source
MurmurHash3.scala
final def productHash(x: Product, seed: Int, ignorePrefix: Boolean): Int

Compute the hash of a product

Compute the hash of a product

Attributes

Inherited from:
MurmurHash3 (hidden)
Source
MurmurHash3.scala
final def rangeHash(start: Int, step: Int, last: Int, seed: Int): Int

Compute the hash of a Range with at least 2 elements.

Compute the hash of a Range with at least 2 elements. Ranges with fewer elements need to use seqHash instead. The last parameter must be the actual last element produced by a Range, not the nominal end.

Attributes

Inherited from:
MurmurHash3 (hidden)
Source
MurmurHash3.scala
final def stringHash(str: String, seed: Int): Int

Compute the hash of a string

Compute the hash of a string

Attributes

Inherited from:
MurmurHash3 (hidden)
Source
MurmurHash3.scala
final def unorderedHash(xs: IterableOnce[Any], seed: Int): Int

Compute a hash that is symmetric in its arguments - that is a hash where the order of appearance of elements does not matter.

Compute a hash that is symmetric in its arguments - that is a hash where the order of appearance of elements does not matter. This is useful for hashing sets, for example.

Attributes

Inherited from:
MurmurHash3 (hidden)
Source
MurmurHash3.scala

Concrete fields

final val arraySeed: 1007110753

Attributes

Source
MurmurHash3.scala
final val mapSeed: Int

Attributes

Source
MurmurHash3.scala
final val productSeed: -889275714

Attributes

Source
MurmurHash3.scala
final val seqSeed: Int

Attributes

Source
MurmurHash3.scala
final val setSeed: Int

Attributes

Source
MurmurHash3.scala
final val stringSeed: -137723950

Attributes

Source
MurmurHash3.scala
final val symmetricSeed: -1248659538

Attributes

Source
MurmurHash3.scala
final val traversableSeed: -415593707

Attributes

Source
MurmurHash3.scala