public final class HashUtil extends Object
Modifier and Type | Method and Description |
---|---|
static int |
computePerturbationValue(int capacity)
Computes the key perturbation value applied before hashing.
|
static int |
fastIntMix(int k)
Hash function based on Knuth's multiplicative method.
|
static long |
fastLongMix(long k)
Hash function based on Knuth's multiplicative method.
|
static int |
hashCode(Object... objects)
Hash code for multiple objects using
Arrays.hashCode(Object[]) . |
static int |
hashToIndex(int hash,
int length)
A function that calculates the index (e.g.
|
static int |
MurmurHash3_fmix(int k) |
static long |
MurmurHash3_fmix(long k) |
static long |
MurmurHash3_x64_64_direct(long base,
int offset,
int len) |
static long |
MurmurHash3_x64_64_direct(MemoryAccessor mem,
long base,
int offset,
int len)
Returns the
MurmurHash3_x64_64 hash of a memory block accessed by the provided MemoryAccessor . |
static long |
MurmurHash3_x64_64(byte[] data,
int offset,
int len)
Returns the MurmurHash3_x86_32 hash of a block inside a byte array.
|
static int |
MurmurHash3_x86_32_direct(long base,
int offset,
int len) |
static int |
MurmurHash3_x86_32_direct(MemoryAccessor mem,
long base,
int offset,
int len)
Returns the
MurmurHash3_x86_32 hash of a memory block accessed by the provided MemoryAccessor . |
static int |
MurmurHash3_x86_32(byte[] data,
int offset,
int len)
Returns the MurmurHash3_x86_32 hash of a block inside a byte array.
|
public static int MurmurHash3_x86_32(byte[] data, int offset, int len)
public static int MurmurHash3_x86_32_direct(long base, int offset, int len)
public static int MurmurHash3_x86_32_direct(MemoryAccessor mem, long base, int offset, int len)
MurmurHash3_x86_32
hash of a memory block accessed by the provided MemoryAccessor
.
The MemoryAccessor
will be used to access int
-sized data at addresses (base + offset)
,
(base + offset + 4)
, etc. The caller must ensure that the MemoryAccessor
supports it, especially
when (base + offset)
is not guaranteed to be 4 byte-aligned.public static long MurmurHash3_x64_64(byte[] data, int offset, int len)
public static long MurmurHash3_x64_64_direct(long base, int offset, int len)
public static long MurmurHash3_x64_64_direct(MemoryAccessor mem, long base, int offset, int len)
MurmurHash3_x64_64
hash of a memory block accessed by the provided MemoryAccessor
.
The MemoryAccessor
will be used to access long
-sized data at addresses (base + offset)
,
(base + offset + 8)
, etc. The caller must ensure that the MemoryAccessor
supports it, especially
when (base + offset)
is not guaranteed to be 8 byte-aligned.public static int MurmurHash3_fmix(int k)
public static long MurmurHash3_fmix(long k)
public static long fastLongMix(long k)
k
- the long for which the hash will be calculatedpublic static int fastIntMix(int k)
k
- the integer for which the hash will be calculatedpublic static int hashCode(Object... objects)
Arrays.hashCode(Object[])
.public static int hashToIndex(int hash, int length)
length
- the length of the array/listIllegalArgumentException
- if mod smaller than 1.public static int computePerturbationValue(int capacity)
If it is known that hash containers will not be added to each other (will be used for counting only, for example) then some speed can be gained by not perturbing keys before hashing and returning a value of zero for all possible capacities. The speed gain is a result of faster rehash operation (keys are mostly in order).
Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.