From 9470937b10954667894372cea9d531a67261f7ac Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 2 Jul 2014 15:02:32 +0100 Subject: [PATCH] [btree] When creating a new multilayer btree the initial node should have block_traits, rather than the ValueTraits. --- persistent-data/data-structures/btree.tcc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/persistent-data/data-structures/btree.tcc b/persistent-data/data-structures/btree.tcc index 42ec41e..1234aa0 100644 --- a/persistent-data/data-structures/btree.tcc +++ b/persistent-data/data-structures/btree.tcc @@ -404,11 +404,20 @@ namespace persistent_data { write_ref root = tm_->new_block(validator_); - leaf_node n = to_node(root); - n.set_type(btree_detail::LEAF); - n.set_nr_entries(0); - n.set_max_entries(); - n.set_value_size(sizeof(typename ValueTraits::disk_type)); + if (Levels > 1) { + internal_node n = to_node(root); + n.set_type(btree_detail::LEAF); + n.set_nr_entries(0); + n.set_max_entries(); + n.set_value_size(sizeof(typename block_traits::disk_type)); + + } else { + leaf_node n = to_node(root); + n.set_type(btree_detail::LEAF); + n.set_nr_entries(0); + n.set_max_entries(); + n.set_value_size(sizeof(typename ValueTraits::disk_type)); + } root_ = root.get_location(); }