42 m_filter_size_bits =
floorLog2(m_filter_size);
44 m_sector_bits = m_filter_size_bits - 1;
46 m_temp_filter.resize(m_filter_size);
47 m_filter.resize(m_filter_size);
51 for (
int i = 0;
i < m_filter_size; ++
i) {
63 for (
int i = 0;
i < m_filter_size;
i++) {
90 int set_bits = m_sector_bits;
92 int c0 =
bitSelect(addr, block_bits, block_bits + set_bits - 1);
96 int c1 =
bitSelect(addr, block_bits+set_bits, (block_bits+2*set_bits) - 1);
101 m_filter[c0 + (m_filter_size/2)] = 1;
116 int set_bits = m_sector_bits;
118 int c0 =
bitSelect(addr, block_bits, block_bits + set_bits - 1);
122 int c1 =
bitSelect(addr, block_bits+set_bits, (block_bits+2*set_bits) - 1);
127 m_temp_filter[c0 + (m_filter_size/2)] = 1;
129 m_temp_filter[c1] = 1;
134 for (
int i = 0;
i < m_filter_size/2; ++
i){
136 m_temp_filter[
i] = m_temp_filter[
i] && m_filter[
i];
137 zero = zero || m_temp_filter[
i];
143 m_temp_filter[c0 + (m_filter_size / 2)] = 0;
144 m_temp_filter[c1] = 0;
150 for (
int i = m_filter_size / 2;
i < m_filter_size; ++
i) {
152 m_temp_filter[
i] = m_temp_filter[
i] && m_filter[
i];
153 zero = zero || m_temp_filter[
i];
158 m_temp_filter[c0 + (m_filter_size / 2)] = 0;
159 m_temp_filter[c1] = 0;
163 m_temp_filter[c0 + (m_filter_size / 2)] = 0;
164 m_temp_filter[c1] = 0;
179 for (
int i = 0;
i < m_filter_size;
i++) {
190 return get_index(addr);
216 m_filter_size_bits - 1);
224 Addr part1 =
bitSelect(addr, block_offset, block_offset + 6),
225 part2 =
bitSelect(addr, block_offset + 9, block_offset + 9),
226 part3 =
bitSelect(addr, block_offset + 11, block_offset + 11),
227 part4 =
bitSelect(addr, block_offset + 17, block_offset + 17),
228 part5 =
bitSelect(addr, block_offset + 7, block_offset + 8),
229 part6 =
bitSelect(addr, block_offset + 10, block_offset + 10),
230 part7 =
bitSelect(addr, block_offset + 12, block_offset + 12),
231 part8 =
bitSelect(addr, block_offset + 13, block_offset + 13),
232 part9 =
bitSelect(addr, block_offset + 15, block_offset + 16),
233 part10 =
bitSelect(addr, block_offset + 18, block_offset + 20),
234 part11 =
bitSelect(addr, block_offset + 14, block_offset + 14);
237 (part1 << 14) | (part2 << 13) | (part3 << 12) | (part4 << 11) |
238 (part5 << 9) | (part6 << 8) | (part7 << 7) | (part8 << 6) |
239 (part9 << 4) | (part10 << 1) | (part11);
243 Addr remaining_bits =
244 bitSelect(addr, block_offset + 21, 31) << 21;
245 result = result | remaining_bits;
Addr bitSelect(Addr addr, unsigned int small, unsigned int big)
BulkBloomFilter(int size)
void writeBit(const int index, const int value)
void decrement(Addr addr)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
int readBit(const int index)
int floorLog2(unsigned x)
void increment(Addr addr)
void print(std::ostream &out) const
static uint32_t getBlockSizeBits()
void merge(AbstractBloomFilter *other_filter)