thin-provisioning-tools/era/bloom_tree.h

85 lines
1.9 KiB
C
Raw Normal View History

#ifndef ERA_BLOOM_TREE_H
#define ERA_BLOOM_TREE_H
2014-01-15 05:29:12 +05:30
#include "era/era_detail.h"
#include "persistent-data/data-structures/btree.h"
//----------------------------------------------------------------
2014-01-15 05:29:12 +05:30
namespace era {
namespace bloom_tree_detail {
class damage_visitor;
2014-01-15 05:29:12 +05:30
class damage {
public:
damage(std::string const &desc)
: desc_(desc) {
}
2014-01-15 05:29:12 +05:30
virtual ~damage() {}
virtual void visit(damage_visitor &v) const = 0;
2014-01-15 05:29:12 +05:30
std::string const &get_desc() const {
return desc_;
}
2014-01-15 05:29:12 +05:30
private:
std::string desc_;
};
2014-01-15 05:29:12 +05:30
struct missing_eras : public damage {
missing_eras(std::string const &desc, run<uint32_t> const &eras);
virtual void visit(damage_visitor &v) const;
2014-01-15 05:29:12 +05:30
run<uint32_t> eras_;
};
2014-01-15 05:29:12 +05:30
struct damaged_bloom_filter : public damage {
damaged_bloom_filter(std::string const &desc,
uint32_t era,
run<uint32_t> missing_bits);
virtual void visit(damage_visitor &v) const;
2014-01-15 05:29:12 +05:30
uint32_t era_;
run<uint32_t> missing_bits_;
};
2014-01-15 05:29:12 +05:30
class damage_visitor {
public:
typedef boost::shared_ptr<damage_visitor> ptr;
2014-01-15 05:29:12 +05:30
virtual ~damage_visitor() {}
2014-01-15 05:29:12 +05:30
void visit(damage const &d) {
d.visit(*this);
}
2014-01-15 05:29:12 +05:30
virtual void visit(missing_eras const &d) = 0;
virtual void visit(damaged_bloom_filter const &d) = 0;
};
2014-01-15 05:29:12 +05:30
class bloom_visitor {
public:
typedef boost::shared_ptr<bloom_visitor> ptr;
2014-01-15 05:29:12 +05:30
virtual ~bloom_visitor() {}
virtual void visit(uint32_t index, bool value) = 0;
};
}
2014-01-15 05:29:12 +05:30
typedef persistent_data::btree<1, era_detail_traits> bloom_tree;
2014-01-15 05:29:12 +05:30
void walk_bloom_tree(persistent_data::transaction_manager::ptr tm,
bloom_tree const &tree,
bloom_tree_detail::bloom_visitor &bloom_v,
bloom_tree_detail::damage_visitor &dv);
2014-01-15 05:29:12 +05:30
void check_bloom_tree(persistent_data::transaction_manager::ptr tm,
bloom_tree const &tree,
bloom_tree_detail::damage_visitor &dv);
}
2014-01-15 05:29:12 +05:30
//----------------------------------------------------------------
#endif