- java.lang.Object
- 
- com.pervasive.datarush.commons.util.HashUtil
 
- 
 public final class HashUtil extends Object Utility methods for hashing different data types.These hashes are based on C code placed in the public domain by Bob Jenkins. They are advertised as strong enough to allow the use of hash & maskinstead ofhash % primefor computing a hash bucket.
- 
- 
Field SummaryFields Modifier and Type Field Description static intNULL_HASH_CODEAn arbitrary nonzero constant for the hash code of null valued tokens.
 - 
Constructor SummaryConstructors Constructor Description HashUtil()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static intbinaryHashCode(byte[] bytes)Hash a binary value using Bob Jenkins' "One-at-a-Time Hash".static intbinaryHashCode(byte[] bytes, int offset, int len)Hash a binary value using Bob Jenkins' "One-at-a-Time Hash".static intbooleanHashCode(boolean b)Hashes a boolean value using the same algorithm asintHashCode(int).static intcharHashCode(char c)Hashes a character value using the same algorithm asintHashCode(int).static intdoubleHashCode(double d)Hashes a double value using the same algorithm aslongHashCode(long).static intfinalMix(int a, int b, int c)Replicates the computation of Bob Jenkins' "final" macro.static intfloatHashCode(float f)Hashes a float value using the same algorithm asintHashCode(int).static intintHashCode(int a)Hash a binary value using Bob Jenkins' "4-byte Integer Hashing".static intlongHashCode(long l)Hashes a long value.static intobjectHashCode(Object o)Hashes an object usingObject.hashCode().static inttimestampHashCode(long epochSecs, int nanos)Hashes a timestamp decomposed in seconds and nanos parts.
 
- 
- 
- 
Field Detail- 
NULL_HASH_CODEpublic static final int NULL_HASH_CODE An arbitrary nonzero constant for the hash code of null valued tokens.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
binaryHashCodepublic static final int binaryHashCode(byte[] bytes) Hash a binary value using Bob Jenkins' "One-at-a-Time Hash".- Parameters:
- bytes- the value to hash
- Returns:
- the hash code
 
 - 
binaryHashCodepublic static final int binaryHashCode(byte[] bytes, int offset, int len)Hash a binary value using Bob Jenkins' "One-at-a-Time Hash".- Parameters:
- bytes- the value to hash
- offset- start offset
- len- number of bytes to code
- Returns:
- the hash code
 
 - 
intHashCodepublic static final int intHashCode(int a) Hash a binary value using Bob Jenkins' "4-byte Integer Hashing".- Parameters:
- a- the value to hash
- Returns:
- the hash code
 
 - 
charHashCodepublic static final int charHashCode(char c) Hashes a character value using the same algorithm asintHashCode(int).- Parameters:
- c- the value to hash
- Returns:
- the hash code
 
 - 
booleanHashCodepublic static final int booleanHashCode(boolean b) Hashes a boolean value using the same algorithm asintHashCode(int).- Parameters:
- b- the value to hash
- Returns:
- the hash code
 
 - 
doubleHashCodepublic static final int doubleHashCode(double d) Hashes a double value using the same algorithm aslongHashCode(long).- Parameters:
- d- the value to hash
- Returns:
- the hash code
 
 - 
floatHashCodepublic static final int floatHashCode(float f) Hashes a float value using the same algorithm asintHashCode(int).- Parameters:
- f- the value to hash
- Returns:
- the hash code
 
 - 
longHashCodepublic static final int longHashCode(long l) Hashes a long value.- Parameters:
- l- the value to hash
- Returns:
- the hash code
 
 - 
objectHashCodepublic static final int objectHashCode(Object o) Hashes an object usingObject.hashCode(). Null values are given their own hash code.- Parameters:
- o- the value to hash
- Returns:
- the hash code
 
 - 
timestampHashCodepublic static final int timestampHashCode(long epochSecs, int nanos)Hashes a timestamp decomposed in seconds and nanos parts. Note that time zone offset is deliberately not included. Equal timestamp values in different time zones must have the same hashCode.- Parameters:
- epochSecs- the seconds-since-epoch portion of the timestamp
- nanos- the nanoseconds portion of the timestamp
- Returns:
- the hash code
 
 - 
finalMixpublic static final int finalMix(int a, int b, int c)Replicates the computation of Bob Jenkins' "final" macro.- Parameters:
- a- the first input to the macro
- b- the second input to the macro
- c- the third input to the macro
- Returns:
- the resulting mix
 
 
- 
 
-