include ref_count tree in ref counts

This commit is contained in:
Joe Thornber 2011-08-25 16:27:58 +01:00
parent 3f5e95809f
commit 240e782a07
3 changed files with 27 additions and 7 deletions

View File

@ -331,7 +331,7 @@ namespace persistent_data {
};
// Walks the tree in depth first order
void visit(typename visitor::ptr visitor);
void visit(typename visitor::ptr visitor) const;
private:
template <typename ValueTraits2>
@ -357,7 +357,7 @@ namespace persistent_data {
void walk_tree(typename visitor::ptr visitor,
unsigned level, bool is_root,
block_address b);
block_address b) const;
typename persistent_data::transaction_manager<BlockSize>::ptr tm_;
bool destroy_;

View File

@ -613,7 +613,7 @@ insert_location(btree_detail::shadow_spine<BlockSize> &spine,
template <unsigned Levels, typename ValueTraits, uint32_t BlockSize>
void
btree<Levels, ValueTraits, BlockSize>::visit(typename visitor::ptr visitor)
btree<Levels, ValueTraits, BlockSize>::visit(typename visitor::ptr visitor) const
{
walk_tree(visitor, 0, true, root_);
}
@ -623,7 +623,7 @@ void
btree<Levels, ValueTraits, BlockSize>::
walk_tree(typename visitor::ptr visitor,
unsigned level, bool is_root,
block_address b)
block_address b) const
{
using namespace btree_detail;

View File

@ -112,6 +112,16 @@ namespace persistent_data {
}
};
template <uint32_t BlockSize>
class ref_count_validator : public btree_validator<1, ref_count_traits, BlockSize> {
public:
typedef boost::shared_ptr<ref_count_validator> ptr;
ref_count_validator(block_counter &counter)
: btree_validator<1, ref_count_traits, BlockSize>(counter) {
}
};
template <uint32_t BlockSize>
class sm_disk_base : public persistent_space_map {
public:
@ -233,6 +243,12 @@ namespace persistent_data {
nr_blocks_ = nr_blocks;
}
virtual void check(block_counter &counter) const {
typename ref_count_validator<BlockSize>::ptr v(new ref_count_validator<BlockSize>(counter));
counter.inc(ref_counts_.get_root());
ref_counts_.visit(v);
}
protected:
typename transaction_manager<BlockSize>::ptr get_tm() const {
return tm_;
@ -342,8 +358,11 @@ namespace persistent_data {
::memcpy(dest, &d, sizeof(d));
}
void check(block_counter &counter) {
void check(block_counter &counter) const {
sm_disk_base<BlockSize>::check(counter);
typename bitmap_tree_validator<BlockSize>::ptr v(new bitmap_tree_validator<BlockSize>(counter));
counter.inc(bitmaps_.get_root());
bitmaps_.visit(v);
}
@ -407,9 +426,10 @@ namespace persistent_data {
::memcpy(dest, &d, sizeof(d));
}
void check(block_counter &counter) {
counter.inc(bitmap_root_);
void check(block_counter &counter) const {
sm_disk_base<BlockSize>::check(counter);
counter.inc(bitmap_root_);
for (unsigned i = 0; i < entries_.size(); i++)
counter.inc(entries_[i].blocknr_);
}