Having the block size as a template parameter makes all the code very
verbose, and we're not likely to change it. So this change removes that template arg from everything except the block manager.
This commit is contained in:
@ -14,40 +14,39 @@ using namespace persistent_data;
|
||||
namespace {
|
||||
block_address const NR_BLOCKS = 102400;
|
||||
|
||||
transaction_manager<4096>::ptr
|
||||
transaction_manager::ptr
|
||||
create_tm() {
|
||||
block_manager<4096>::ptr bm(new block_manager<4096>("./test.data", NR_BLOCKS));
|
||||
block_manager<>::ptr bm(new block_manager<>("./test.data", NR_BLOCKS));
|
||||
space_map::ptr sm(new core_map(NR_BLOCKS));
|
||||
transaction_manager<4096>::ptr tm(new transaction_manager<4096>(bm, sm));
|
||||
transaction_manager::ptr tm(new transaction_manager(bm, sm));
|
||||
return tm;
|
||||
}
|
||||
|
||||
btree<1, uint64_traits, 4096>::ptr
|
||||
btree<1, uint64_traits>::ptr
|
||||
create_btree() {
|
||||
uint64_traits::ref_counter rc;
|
||||
|
||||
return btree<1, uint64_traits, 4096>::ptr(
|
||||
new btree<1, uint64_traits, 4096>(
|
||||
create_tm(), rc));
|
||||
return btree<1, uint64_traits>::ptr(
|
||||
new btree<1, uint64_traits>(create_tm(), rc));
|
||||
}
|
||||
|
||||
// Checks that a btree is well formed.
|
||||
//
|
||||
// i) No block should be in the tree more than once.
|
||||
//
|
||||
class constraint_visitor : public btree<1, uint64_traits, 4096>::visitor {
|
||||
class constraint_visitor : public btree<1, uint64_traits>::visitor {
|
||||
public:
|
||||
bool visit_internal(unsigned level, bool is_root, btree_detail::node_ref<uint64_traits, 4096> const &n) {
|
||||
bool visit_internal(unsigned level, bool is_root, btree_detail::node_ref<uint64_traits> const &n) {
|
||||
check_duplicate_block(n.get_location());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool visit_internal_leaf(unsigned level, bool is_root, btree_detail::node_ref<uint64_traits, 4096> const &n) {
|
||||
bool visit_internal_leaf(unsigned level, bool is_root, btree_detail::node_ref<uint64_traits> const &n) {
|
||||
check_duplicate_block(n.get_location());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool visit_leaf(unsigned level, bool is_root, btree_detail::node_ref<uint64_traits, 4096> const &n) {
|
||||
bool visit_leaf(unsigned level, bool is_root, btree_detail::node_ref<uint64_traits> const &n) {
|
||||
check_duplicate_block(n.get_location());
|
||||
return true;
|
||||
}
|
||||
@ -66,8 +65,8 @@ namespace {
|
||||
set<block_address> seen_;
|
||||
};
|
||||
|
||||
void check_constraints(btree<1, uint64_traits, 4096>::ptr tree) {
|
||||
typedef btree<1, uint64_traits, 4096> tree_type;
|
||||
void check_constraints(btree<1, uint64_traits>::ptr tree) {
|
||||
typedef btree<1, uint64_traits> tree_type;
|
||||
|
||||
tree_type::visitor::ptr v(new constraint_visitor);
|
||||
tree->visit(v);
|
||||
|
@ -13,22 +13,21 @@ using namespace persistent_data;
|
||||
namespace {
|
||||
block_address const NR_BLOCKS = 10237;
|
||||
block_address const SUPERBLOCK = 0;
|
||||
unsigned const BLOCK_SIZE = 4096;
|
||||
|
||||
transaction_manager<BLOCK_SIZE>::ptr
|
||||
transaction_manager::ptr
|
||||
create_tm() {
|
||||
block_manager<BLOCK_SIZE>::ptr bm(
|
||||
new block_manager<BLOCK_SIZE>("./test.data", NR_BLOCKS));
|
||||
block_manager<>::ptr bm(
|
||||
new block_manager<>("./test.data", NR_BLOCKS));
|
||||
space_map::ptr sm(new core_map(1024));
|
||||
transaction_manager<BLOCK_SIZE>::ptr tm(
|
||||
new transaction_manager<BLOCK_SIZE>(bm, sm));
|
||||
transaction_manager::ptr tm(
|
||||
new transaction_manager(bm, sm));
|
||||
return tm;
|
||||
}
|
||||
|
||||
persistent_space_map::ptr
|
||||
create_sm_disk() {
|
||||
auto tm = create_tm();
|
||||
return persistent_data::create_disk_sm<BLOCK_SIZE>(tm, NR_BLOCKS);
|
||||
return persistent_data::create_disk_sm(tm, NR_BLOCKS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +135,7 @@ BOOST_AUTO_TEST_CASE(test_reopen)
|
||||
|
||||
{
|
||||
auto tm = create_tm();
|
||||
auto sm = persistent_data::open_disk_sm<BLOCK_SIZE>(tm, buffer);
|
||||
auto sm = persistent_data::open_disk_sm(tm, buffer);
|
||||
|
||||
for (unsigned i = 0, step = 1; i < NR_BLOCKS; i += step, step++)
|
||||
BOOST_CHECK_EQUAL(sm->get_count(i), 1);
|
||||
|
@ -13,11 +13,11 @@ using namespace persistent_data;
|
||||
namespace {
|
||||
block_address const NR_BLOCKS = 1024;
|
||||
|
||||
transaction_manager<4096>::ptr
|
||||
transaction_manager::ptr
|
||||
create_tm() {
|
||||
block_manager<4096>::ptr bm(new block_manager<4096>("./test.data", NR_BLOCKS));
|
||||
block_manager<>::ptr bm(new block_manager<>("./test.data", NR_BLOCKS));
|
||||
space_map::ptr sm(new core_map(NR_BLOCKS));
|
||||
transaction_manager<4096>::ptr tm(new transaction_manager<4096>(bm, sm));
|
||||
transaction_manager::ptr tm(new transaction_manager(bm, sm));
|
||||
tm->get_sm()->inc(0);
|
||||
return tm;
|
||||
}
|
||||
|
Reference in New Issue
Block a user