Package com.google.common.hash
Enum BloomFilterStrategies
- java.lang.Object
-
- java.lang.Enum<BloomFilterStrategies>
-
- com.google.common.hash.BloomFilterStrategies
-
- All Implemented Interfaces:
BloomFilter.Strategy
,java.io.Serializable
,java.lang.Comparable<BloomFilterStrategies>
enum BloomFilterStrategies extends java.lang.Enum<BloomFilterStrategies> implements BloomFilter.Strategy
Collections of strategies of generating the k * log(M) bits required for an element to be mapped to a BloomFilter of M bits and k hash functions. These strategies are part of the serialized form of the Bloom filters that use them, thus they must be preserved as is (no updates allowed, only introduction of new versions). Important: the order of the constants cannot change, and they cannot be deleted - we depend on their ordinal for BloomFilter serialization.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
BloomFilterStrategies.BitArray
-
Enum Constant Summary
Enum Constants Enum Constant Description MURMUR128_MITZ_32
See "Less Hashing, Same Performance: Building a Better Bloom Filter" by Adam Kirsch and Michael Mitzenmacher.MURMUR128_MITZ_64
This strategy uses all 128 bits ofHashing.murmur3_128(int)
when hashing.
-
Constructor Summary
Constructors Modifier Constructor Description private
BloomFilterStrategies()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BloomFilterStrategies
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static BloomFilterStrategies[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Methods inherited from interface com.google.common.hash.BloomFilter.Strategy
mightContain, ordinal, put
-
-
-
-
Enum Constant Detail
-
MURMUR128_MITZ_32
public static final BloomFilterStrategies MURMUR128_MITZ_32
See "Less Hashing, Same Performance: Building a Better Bloom Filter" by Adam Kirsch and Michael Mitzenmacher. The paper argues that this trick doesn't significantly deteriorate the performance of a Bloom filter (yet only needs two 32bit hash functions).
-
MURMUR128_MITZ_64
public static final BloomFilterStrategies MURMUR128_MITZ_64
This strategy uses all 128 bits ofHashing.murmur3_128(int)
when hashing. It looks different than the implementation in MURMUR128_MITZ_32 because we're avoiding the multiplication in the loop and doing a (much simpler) += hash2. We're also changing the index to a positive number by AND'ing with Long.MAX_VALUE instead of flipping the bits.
-
-
Method Detail
-
values
public static BloomFilterStrategies[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (BloomFilterStrategies c : BloomFilterStrategies.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static BloomFilterStrategies valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
-