Class Murmur3HashFunction
java.lang.Object
cloud.opencode.base.hash.function.AbstractHashFunction
cloud.opencode.base.hash.function.Murmur3HashFunction
- All Implemented Interfaces:
HashFunction
MurmurHash3 hash function implementation
MurmurHash3 哈希函数实现
MurmurHash3 is a non-cryptographic hash function that provides excellent distribution and collision resistance with high performance.
MurmurHash3 是一种非加密哈希函数,提供出色的分布和碰撞阻力,性能高。
Features | 主要功能:
- 32-bit and 128-bit variants - 32位和128位变体
- Configurable seed value - 可配置的种子值
- High performance - 高性能
- Good distribution - 良好的分布
Usage Examples | 使用示例:
// 32-bit hash
HashCode hash32 = Murmur3HashFunction.murmur3_32().hashUtf8("Hello");
// 128-bit hash with seed
HashCode hash128 = Murmur3HashFunction.murmur3_128(42).hashBytes(data);
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Not for cryptographic use - 不用于加密用途
Performance | 性能特性:
- Time complexity: O(n) where n = input size - O(n), n为输入大小
- Space complexity: O(1) - O(1)
- Since:
- JDK 25, opencode-base-hash V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractHashFunction
AbstractHashFunction.AbstractHasher, AbstractHashFunction.BufferedHasher -
Field Summary
Fields inherited from class AbstractHashFunction
bits, name -
Method Summary
Modifier and TypeMethodDescriptionhashBytes(byte[] input, int offset, int length) Computes hash of a byte array portion 计算字节数组部分的哈希static Murmur3HashFunctionCreates a 128-bit MurmurHash3 function with default seed 使用默认种子创建128位MurmurHash3函数static Murmur3HashFunctionmurmur3_128(int seed) Creates a 128-bit MurmurHash3 function with specified seed 使用指定种子创建128位MurmurHash3函数static Murmur3HashFunctionCreates a 32-bit MurmurHash3 function with default seed 使用默认种子创建32位MurmurHash3函数static Murmur3HashFunctionmurmur3_32(int seed) Creates a 32-bit MurmurHash3 function with specified seed 使用指定种子创建32位MurmurHash3函数Creates a new Hasher instance for streaming hash computation 创建新的Hasher实例用于流式哈希计算Methods inherited from class AbstractHashFunction
bits, hashBytes, hashInt, hashLong, hashObject, name, newHasher, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface HashFunction
hashFile, hashInputStream, hashString, hashUtf8
-
Method Details
-
murmur3_32
Creates a 32-bit MurmurHash3 function with default seed 使用默认种子创建32位MurmurHash3函数- Returns:
- hash function | 哈希函数
-
murmur3_32
Creates a 32-bit MurmurHash3 function with specified seed 使用指定种子创建32位MurmurHash3函数- Parameters:
seed- seed value | 种子值- Returns:
- hash function | 哈希函数
-
murmur3_128
Creates a 128-bit MurmurHash3 function with default seed 使用默认种子创建128位MurmurHash3函数- Returns:
- hash function | 哈希函数
-
murmur3_128
Creates a 128-bit MurmurHash3 function with specified seed 使用指定种子创建128位MurmurHash3函数- Parameters:
seed- seed value | 种子值- Returns:
- hash function | 哈希函数
-
newHasher
Description copied from interface:HashFunctionCreates a new Hasher instance for streaming hash computation 创建新的Hasher实例用于流式哈希计算- Returns:
- a new Hasher (stateful, not thread-safe) | 新的Hasher(有状态,非线程安全)
-
hashBytes
Description copied from interface:HashFunctionComputes hash of a byte array portion 计算字节数组部分的哈希- Parameters:
input- input bytes | 输入字节offset- starting offset | 起始偏移length- number of bytes to hash | 要哈希的字节数- Returns:
- hash code | 哈希码
-