Package org.apache.hadoop.hbase.util
Class Hash
java.lang.Object
org.apache.hadoop.hbase.util.Hash
- Direct Known Subclasses:
JenkinsHash
,MurmurHash
,MurmurHash3
This class represents a common API for hashing functions.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Constant to denote invalid hash type.static final int
Constant to denoteJenkinsHash
.static final int
Constant to denoteMurmurHash
.static final int
Constant to denoteMurmurHash3
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
getHashType
(org.apache.hadoop.conf.Configuration conf) This utility method converts the name of the configured hash type to a symbolic constant.static Hash
getInstance
(int type) Get a singleton instance of hash function of a given type.static Hash
getInstance
(org.apache.hadoop.conf.Configuration conf) Get a singleton instance of hash function of a type defined in the configuration.abstract <T> int
Calculate a hash using bytes from HashKey and the provided seed value.static int
parseHashType
(String name) This utility method converts String representation of hash function name to a symbolic constant.
-
Field Details
-
INVALID_HASH
Constant to denote invalid hash type.- See Also:
-
JENKINS_HASH
Constant to denoteJenkinsHash
.- See Also:
-
MURMUR_HASH
Constant to denoteMurmurHash
.- See Also:
-
MURMUR_HASH3
Constant to denoteMurmurHash3
.- See Also:
-
-
Constructor Details
-
Hash
public Hash()
-
-
Method Details
-
parseHashType
This utility method converts String representation of hash function name to a symbolic constant. Currently three function types are supported, "jenkins", "murmur" and "murmur3".- Parameters:
name
- hash function name- Returns:
- one of the predefined constants
-
getHashType
This utility method converts the name of the configured hash type to a symbolic constant.- Parameters:
conf
- configuration- Returns:
- one of the predefined constants
-
getInstance
Get a singleton instance of hash function of a given type.- Parameters:
type
- predefined hash type- Returns:
- hash function instance, or null if type is invalid
-
getInstance
Get a singleton instance of hash function of a type defined in the configuration.- Parameters:
conf
- current configuration- Returns:
- defined hash type, or null if type is invalid
-
hash
Calculate a hash using bytes from HashKey and the provided seed value.- Parameters:
hashKey
- key to extract the hashinitval
- the seed value- Returns:
- hash value
-