Package org.h2.dev.hash
Class MinimalPerfectHash.StringHash
java.lang.Object
org.h2.dev.hash.MinimalPerfectHash.StringHash
- All Implemented Interfaces:
MinimalPerfectHash.UniversalHash<String>
- Enclosing class:
- MinimalPerfectHash<K>
public static class MinimalPerfectHash.StringHash
extends Object
implements MinimalPerfectHash.UniversalHash<String>
A sample hash implementation for integer keys.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intgetFastHash(String o, int index, int seed) A cryptographically weak hash function.static intgetSipHash24(byte[] b, int start, int end, long k0, long k1) A cryptographically relatively secure hash function.static intgetSipHash24(String o, long k0, long k1) A cryptographically relatively secure hash function.intCalculate the hash of the given object.
-
Constructor Details
-
StringHash
public StringHash()
-
-
Method Details
-
hashCode
Description copied from interface:MinimalPerfectHash.UniversalHashCalculate the hash of the given object.- Specified by:
hashCodein interfaceMinimalPerfectHash.UniversalHash<String>- Parameters:
o- the objectindex- the hash function index (index 0 is used first, so the method should be very fast with index 0; index 1 and so on are only called when really needed)seed- the random seed (always the same for a hash table)- Returns:
- the hash value
-
getFastHash
A cryptographically weak hash function. It is supposed to be fast.- Parameters:
o- the stringindex- the hash function indexseed- the seed- Returns:
- the hash value
-
getSipHash24
A cryptographically relatively secure hash function. It is supposed to protected against hash-flooding denial-of-service attacks.- Parameters:
o- the stringk0- key 0k1- key 1- Returns:
- the hash value
-
getSipHash24
public static int getSipHash24(byte[] b, int start, int end, long k0, long k1) A cryptographically relatively secure hash function. It is supposed to protected against hash-flooding denial-of-service attacks.- Parameters:
b- the datastart- the start positionend- the end position plus onek0- key 0k1- key 1- Returns:
- the hash value
-