* A bloom filter that represents a window * within a larger bloom filter. */
| 15 | * within a larger bloom filter. |
| 16 | */ |
| 17 | class BloomFilterWindow : public Konnector::BloomFilter |
| 18 | { |
| 19 | public: |
| 20 | |
| 21 | /** Constructor. */ |
| 22 | BloomFilterWindow() : Konnector::BloomFilter() { }; |
| 23 | |
| 24 | /** Constructor. |
| 25 | * |
| 26 | * @param fullBloomSize size in bits of the containing bloom filter |
| 27 | * @param startBitPos index of first bit in the window |
| 28 | * @param endBitPos index of last bit in the window |
| 29 | */ |
| 30 | BloomFilterWindow(size_t fullBloomSize, size_t startBitPos, |
| 31 | size_t endBitPos, size_t hashSeed=0) : |
| 32 | Konnector::BloomFilter(endBitPos - startBitPos + 1, hashSeed), |
| 33 | m_fullBloomSize(fullBloomSize), |
| 34 | m_startBitPos(startBitPos), |
| 35 | m_endBitPos(endBitPos) |
| 36 | { |
| 37 | assert(startBitPos < fullBloomSize); |
| 38 | assert(endBitPos < fullBloomSize); |
| 39 | assert(startBitPos <= endBitPos); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Get the full size (in bits) of the bloom filter that |
| 44 | * this window is a part of. |
| 45 | */ |
| 46 | size_t fullBloomSize() |
| 47 | { |
| 48 | return m_fullBloomSize; |
| 49 | } |
| 50 | |
| 51 | /** Get the start bit position for the window. */ |
| 52 | size_t startBitPos() |
| 53 | { |
| 54 | return m_startBitPos; |
| 55 | } |
| 56 | |
| 57 | /** Get the end bit position for the window. */ |
| 58 | size_t endBitPos() |
| 59 | { |
| 60 | return m_endBitPos; |
| 61 | } |
| 62 | |
| 63 | /** Return the size of the bit array. */ |
| 64 | size_t size() const |
| 65 | { |
| 66 | return Konnector::BloomFilter::size(); |
| 67 | } |
| 68 | |
| 69 | /** Return the number of elements with count >= max_count. */ |
| 70 | size_t popcount() const |
| 71 | { |
| 72 | return Konnector::BloomFilter::popcount(); |
| 73 | } |
| 74 |