FARGOS/VISTA Object Management Environment Core
..
|
Templated Bloom filter. More...
#include <bloom_filter.hpp>
Public Member Functions | |
BloomFilterForKey () | |
Construct a Bloom filter. More... | |
~BloomFilterForKey () | |
void | clear () |
Clear all presence bits from the Bloom filter. More... | |
void | addKey (KEYTYPE key) OME_ALWAYS_INLINE |
Add a key to the Bloom filter. More... | |
bool | couldBeSelected (KEYTYPE key) const OME_ALWAYS_INLINE |
Test to see if key could be of interest. More... | |
Protected Types | |
enum | { BIT_WIDTH = sizeof(HASHTYPE) * 8, TBL_SIZE = (1 << BIT_WIDTH), HASH_MASK = (1 << BIT_WIDTH) - 1 } |
Protected Member Functions | |
HASHTYPE | hash1 (KEYTYPE key) const OME_CONST_FUNCTION |
Hash 1 for Bloom filter. More... | |
HASHTYPE | hash2 (KEYTYPE key) const OME_CONST_FUNCTION |
HASHTYPE | hash3 (KEYTYPE key) const OME_CONST_FUNCTION |
void | setPresenceBit (HASHTYPE hashedVal) |
bool | isPresenceBitSet (HASHTYPE hashedVal) const |
Protected Attributes | |
uint64_t | presenceTable [TBL_SIZE/64] |
Templated Bloom filter.
HASHTYPE | is the type of the result of the hash function. |
KEYTYPE | is the type of the key to be hashed. |
The Bloom filter is a probabilistic data structure that can be used to quickly discard keys as not being of interest. This is achieved by testing up to 3 distinct hashes that resolve to bits within a logical array of bits. If a key to be tested does not hash to any value that has a bit set, one can authoritatively conclude that the key was never previously selected.
In contrast, if one of the hashes does correspond to an already set bit, one can only conclude that there is a possibility that the key might be of interest.
Typical usage is in processing subscriptions to data feeds that serve a large population of potential keys for which only a small subset is usually of interest.
|
protected |
|
inline |
Construct a Bloom filter.
References BloomFilterForKey< HASHTYPE, KEYTYPE >::presenceTable.
|
inline |
|
inline |
Add a key to the Bloom filter.
key | specifies the key to add to the Bloom filter |
References BloomFilterForKey< HASHTYPE, KEYTYPE >::hash1(), BloomFilterForKey< HASHTYPE, KEYTYPE >::hash2(), BloomFilterForKey< HASHTYPE, KEYTYPE >::hash3(), and BloomFilterForKey< HASHTYPE, KEYTYPE >::setPresenceBit().
|
inline |
Clear all presence bits from the Bloom filter.
References BloomFilterForKey< HASHTYPE, KEYTYPE >::presenceTable.
|
inline |
Test to see if key could be of interest.
key | specifies the key to test |
false | It is not possible for the key to have been previously added to the filter. |
true | It is possible, but not guaranteed, that the key may have been added to the filter. |
References BloomFilterForKey< HASHTYPE, KEYTYPE >::hash1(), BloomFilterForKey< HASHTYPE, KEYTYPE >::hash2(), BloomFilterForKey< HASHTYPE, KEYTYPE >::hash3(), and BloomFilterForKey< HASHTYPE, KEYTYPE >::isPresenceBitSet().
|
inlineprotected |
Hash 1 for Bloom filter.
References BloomFilterForKey< HASHTYPE, KEYTYPE >::BIT_WIDTH.
Referenced by BloomFilterForKey< HASHTYPE, KEYTYPE >::addKey(), and BloomFilterForKey< HASHTYPE, KEYTYPE >::couldBeSelected().
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
References OME_PREFETCH, and BloomFilterForKey< HASHTYPE, KEYTYPE >::presenceTable.
Referenced by BloomFilterForKey< HASHTYPE, KEYTYPE >::couldBeSelected().
|
inlineprotected |
References OME_PREFETCH, and BloomFilterForKey< HASHTYPE, KEYTYPE >::presenceTable.
Referenced by BloomFilterForKey< HASHTYPE, KEYTYPE >::addKey().
|
protected |
![]() | Generated: Fri Jul 31 2020 18:19:16
Support Information |