FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents
BloomFilterForKey< HASHTYPE, KEYTYPE > Class Template Reference

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]
 

Detailed Description

template<typename HASHTYPE, typename KEYTYPE = uint32_t>
class BloomFilterForKey< HASHTYPE, KEYTYPE >

Templated Bloom filter.

Parameters
HASHTYPEis the type of the result of the hash function.
KEYTYPEis 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.

Member Enumeration Documentation

◆ anonymous enum

template<typename HASHTYPE , typename KEYTYPE = uint32_t>
anonymous enum
protected
Enumerator
BIT_WIDTH 
TBL_SIZE 
HASH_MASK 

Constructor & Destructor Documentation

◆ BloomFilterForKey()

template<typename HASHTYPE , typename KEYTYPE = uint32_t>
BloomFilterForKey< HASHTYPE, KEYTYPE >::BloomFilterForKey ( )
inline

Construct a Bloom filter.

References BloomFilterForKey< HASHTYPE, KEYTYPE >::presenceTable.

◆ ~BloomFilterForKey()

template<typename HASHTYPE , typename KEYTYPE = uint32_t>
BloomFilterForKey< HASHTYPE, KEYTYPE >::~BloomFilterForKey ( )
inline

Member Function Documentation

◆ addKey()

template<typename HASHTYPE , typename KEYTYPE = uint32_t>
void BloomFilterForKey< HASHTYPE, KEYTYPE >::addKey ( KEYTYPE  key)
inline

◆ clear()

template<typename HASHTYPE , typename KEYTYPE = uint32_t>
void BloomFilterForKey< HASHTYPE, KEYTYPE >::clear ( )
inline

Clear all presence bits from the Bloom filter.

References BloomFilterForKey< HASHTYPE, KEYTYPE >::presenceTable.

◆ couldBeSelected()

template<typename HASHTYPE , typename KEYTYPE = uint32_t>
bool BloomFilterForKey< HASHTYPE, KEYTYPE >::couldBeSelected ( KEYTYPE  key) const
inline

Test to see if key could be of interest.

Parameters
keyspecifies the key to test
Return values
falseIt is not possible for the key to have been previously added to the filter.
trueIt 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().

◆ hash1()

template<typename HASHTYPE , typename KEYTYPE = uint32_t>
HASHTYPE BloomFilterForKey< HASHTYPE, KEYTYPE >::hash1 ( KEYTYPE  key) const
inlineprotected

◆ hash2()

template<typename HASHTYPE , typename KEYTYPE = uint32_t>
HASHTYPE BloomFilterForKey< HASHTYPE, KEYTYPE >::hash2 ( KEYTYPE  key) const
inlineprotected

◆ hash3()

template<typename HASHTYPE , typename KEYTYPE = uint32_t>
HASHTYPE BloomFilterForKey< HASHTYPE, KEYTYPE >::hash3 ( KEYTYPE  key) const
inlineprotected

◆ isPresenceBitSet()

template<typename HASHTYPE , typename KEYTYPE = uint32_t>
bool BloomFilterForKey< HASHTYPE, KEYTYPE >::isPresenceBitSet ( HASHTYPE  hashedVal) const
inlineprotected

◆ setPresenceBit()

template<typename HASHTYPE , typename KEYTYPE = uint32_t>
void BloomFilterForKey< HASHTYPE, KEYTYPE >::setPresenceBit ( HASHTYPE  hashedVal)
inlineprotected

Member Data Documentation

◆ presenceTable


The documentation for this class was generated from the following file:
Generated: Fri Jul 31 2020 18:19:16
Support Information