public static class MurmurHash3.IncrementalHash32x86
extends java.lang.Object
This is an implementation of the 32-bit hash function MurmurHash3_x86_32
from from Austin Applyby's original MurmurHash3 c++
code in SMHasher.
Modifier and Type | Field and Description |
---|---|
private static int |
BLOCK_SIZE
The size of byte blocks that are processed together.
|
private int |
hash
The current running hash.
|
private int |
totalLen
The total number of input bytes added since the start.
|
private byte[] |
unprocessed
Up to 3 unprocessed bytes from input data.
|
private int |
unprocessedLength
The number of unprocessed bytes in the tail data.
|
Constructor and Description |
---|
IncrementalHash32x86() |
Modifier and Type | Method and Description |
---|---|
void |
add(byte[] data,
int offset,
int length)
Adds the byte array to the current incremental hash.
|
int |
end()
Generate the 32-bit hash value.
|
(package private) int |
finalise(int hash,
int unprocessedLength,
byte[] unprocessed,
int totalLen)
Finalize the running hash to the output 32-bit hash by processing remaining bytes
and performing final mixing.
|
private static int |
orBytes(byte b1,
byte b2,
byte b3,
byte b4)
Combines the bytes using an Or operation (
| in a little-endian representation
of a 32-bit integer; byte 1 will be the least significant byte, byte 4 the most
significant. |
void |
start(int seed)
Starts a new incremental hash.
|
private static final int BLOCK_SIZE
private final byte[] unprocessed
private int unprocessedLength
private int totalLen
private int hash
public final void start(int seed)
seed
- The initial seed valuepublic final void add(byte[] data, int offset, int length)
data
- The input byte arrayoffset
- The offset of datalength
- The length of arraypublic final int end()
int finalise(int hash, int unprocessedLength, byte[] unprocessed, int totalLen)
hash
- The running hashunprocessedLength
- The number of unprocessed bytes in the tail data.unprocessed
- Up to 3 unprocessed bytes from input data.totalLen
- The total number of input bytes added since the start.private static int orBytes(byte b1, byte b2, byte b3, byte b4)
|
in a little-endian representation
of a 32-bit integer; byte 1 will be the least significant byte, byte 4 the most
significant.b1
- The first byteb2
- The second byteb3
- The third byteb4
- The fourth byte