2013-11-18 18:38:07 +05:30
|
|
|
#ifndef PERSISTENT_DATA_DATA_STRUCTURES_BLOOM_FILTER_H
|
|
|
|
#define PERSISTENT_DATA_DATA_STRUCTURES_BLOOM_FILTER_H
|
|
|
|
|
|
|
|
#include "persistent-data/transaction_manager.h"
|
|
|
|
#include "persistent-data/data-structures/bitset.h"
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
namespace persistent_data {
|
|
|
|
class bloom_filter {
|
|
|
|
public:
|
2020-04-30 19:32:43 +05:30
|
|
|
typedef std::shared_ptr<bloom_filter> ptr;
|
2013-11-18 18:38:07 +05:30
|
|
|
|
|
|
|
// nr_bits must be a power of two
|
2014-08-26 15:44:49 +05:30
|
|
|
bloom_filter(transaction_manager &tm,
|
2013-11-18 18:38:07 +05:30
|
|
|
unsigned nr_bits, unsigned nr_probes);
|
|
|
|
|
2014-08-26 15:44:49 +05:30
|
|
|
bloom_filter(transaction_manager &tm, block_address root,
|
2013-11-18 18:38:07 +05:30
|
|
|
unsigned nr_bits_power, unsigned nr_probes);
|
|
|
|
|
|
|
|
block_address get_root() const;
|
|
|
|
|
|
|
|
bool test(uint64_t b); // not const due to caching effects in bitset
|
|
|
|
void set(uint64_t b);
|
|
|
|
void flush();
|
|
|
|
|
2017-04-29 23:21:52 +05:30
|
|
|
void print_debug(std::ostream &out);
|
2013-11-18 18:38:07 +05:30
|
|
|
|
|
|
|
private:
|
2017-04-29 23:21:52 +05:30
|
|
|
void print_residency(std::ostream &out);
|
2013-11-18 18:38:07 +05:30
|
|
|
|
2017-04-29 23:21:52 +05:30
|
|
|
void fill_probes(block_address b, std::vector<unsigned> &probes) const;
|
2013-11-18 18:38:07 +05:30
|
|
|
|
|
|
|
persistent_data::bitset bits_;
|
|
|
|
unsigned nr_probes_;
|
|
|
|
uint64_t mask_;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
#endif
|