Remove some more global using namespaces

This commit is contained in:
Joe Thornber 2013-05-28 13:53:23 +01:00
parent 6706493304
commit 480e94d4eb

View File

@ -24,15 +24,14 @@
#include <iostream> #include <iostream>
// FIXME: remove
using namespace base;
using namespace persistent_data;
using namespace btree_detail;
using namespace std;
//---------------------------------------------------------------- //----------------------------------------------------------------
namespace { namespace {
using namespace base;
using namespace persistent_data;
using namespace btree_detail;
using namespace std;
struct btree_node_validator : public block_manager<>::validator { struct btree_node_validator : public block_manager<>::validator {
virtual void check(buffer<> const &b, block_address location) const { virtual void check(buffer<> const &b, block_address location) const {
disk_node const *data = reinterpret_cast<disk_node const *>(&b); disk_node const *data = reinterpret_cast<disk_node const *>(&b);
@ -60,17 +59,18 @@ namespace {
//---------------------------------------------------------------- //----------------------------------------------------------------
inline void namespace persistent_data {
ro_spine::step(block_address b) inline void
{ ro_spine::step(block_address b)
{
spine_.push_back(tm_->read_lock(b, validator_)); spine_.push_back(tm_->read_lock(b, validator_));
if (spine_.size() > 2) if (spine_.size() > 2)
spine_.pop_front(); spine_.pop_front();
} }
inline bool inline bool
shadow_spine::step(block_address b) shadow_spine::step(block_address b)
{ {
pair<write_ref, bool> p = tm_->shadow(b, validator_); pair<write_ref, bool> p = tm_->shadow(b, validator_);
try { try {
step(p.first); step(p.first);
@ -79,35 +79,35 @@ shadow_spine::step(block_address b)
throw; throw;
} }
return p.second; return p.second;
} }
//---------------------------------------------------------------- //----------------------------------------------------------------
template <typename ValueTraits> template <typename ValueTraits>
node_ref<ValueTraits>::node_ref(block_address location, disk_node *raw) node_ref<ValueTraits>::node_ref(block_address location, disk_node *raw)
: location_(location), : location_(location),
raw_(raw) raw_(raw)
{ {
} }
template <typename ValueTraits> template <typename ValueTraits>
uint32_t uint32_t
node_ref<ValueTraits>::get_checksum() const node_ref<ValueTraits>::get_checksum() const
{ {
return to_cpu<uint32_t>(raw_->header.csum); return to_cpu<uint32_t>(raw_->header.csum);
} }
template <typename ValueTraits> template <typename ValueTraits>
block_address block_address
node_ref<ValueTraits>::get_block_nr() const node_ref<ValueTraits>::get_block_nr() const
{ {
return to_cpu<uint64_t>(raw_->header.blocknr); return to_cpu<uint64_t>(raw_->header.blocknr);
} }
template <typename ValueTraits> template <typename ValueTraits>
btree_detail::node_type btree_detail::node_type
node_ref<ValueTraits>::get_type() const node_ref<ValueTraits>::get_type() const
{ {
uint32_t flags = to_cpu<uint32_t>(raw_->header.flags); uint32_t flags = to_cpu<uint32_t>(raw_->header.flags);
if (flags & INTERNAL_NODE) { if (flags & INTERNAL_NODE) {
if (flags & LEAF_NODE) if (flags & LEAF_NODE)
@ -118,12 +118,12 @@ node_ref<ValueTraits>::get_type() const
return LEAF; return LEAF;
else else
throw runtime_error("unknown node type"); throw runtime_error("unknown node type");
} }
template <typename ValueTraits> template <typename ValueTraits>
void void
node_ref<ValueTraits>::set_type(node_type t) node_ref<ValueTraits>::set_type(node_type t)
{ {
uint32_t flags = to_cpu<uint32_t>(raw_->header.flags); uint32_t flags = to_cpu<uint32_t>(raw_->header.flags);
switch (t) { switch (t) {
case INTERNAL: case INTERNAL:
@ -135,77 +135,77 @@ node_ref<ValueTraits>::set_type(node_type t)
break; break;
} }
raw_->header.flags = to_disk<le32>(flags); raw_->header.flags = to_disk<le32>(flags);
} }
template <typename ValueTraits> template <typename ValueTraits>
unsigned unsigned
node_ref<ValueTraits>::get_nr_entries() const node_ref<ValueTraits>::get_nr_entries() const
{ {
return to_cpu<uint32_t>(raw_->header.nr_entries); return to_cpu<uint32_t>(raw_->header.nr_entries);
} }
template <typename ValueTraits> template <typename ValueTraits>
void void
node_ref<ValueTraits>::set_nr_entries(unsigned n) node_ref<ValueTraits>::set_nr_entries(unsigned n)
{ {
raw_->header.nr_entries = to_disk<le32>(n); raw_->header.nr_entries = to_disk<le32>(n);
} }
template <typename ValueTraits> template <typename ValueTraits>
unsigned unsigned
node_ref<ValueTraits>::get_max_entries() const node_ref<ValueTraits>::get_max_entries() const
{ {
return to_cpu<uint32_t>(raw_->header.max_entries); return to_cpu<uint32_t>(raw_->header.max_entries);
} }
template <typename ValueTraits> template <typename ValueTraits>
void void
node_ref<ValueTraits>::set_max_entries(unsigned n) node_ref<ValueTraits>::set_max_entries(unsigned n)
{ {
raw_->header.max_entries = to_disk<le32>(n); raw_->header.max_entries = to_disk<le32>(n);
} }
template <typename ValueTraits> template <typename ValueTraits>
void void
node_ref<ValueTraits>::set_max_entries() node_ref<ValueTraits>::set_max_entries()
{ {
set_max_entries(calc_max_entries()); set_max_entries(calc_max_entries());
} }
template <typename ValueTraits> template <typename ValueTraits>
size_t size_t
node_ref<ValueTraits>::get_value_size() const node_ref<ValueTraits>::get_value_size() const
{ {
return to_cpu<uint32_t>(raw_->header.value_size); return to_cpu<uint32_t>(raw_->header.value_size);
} }
template <typename ValueTraits> template <typename ValueTraits>
void void
node_ref<ValueTraits>::set_value_size(size_t s) node_ref<ValueTraits>::set_value_size(size_t s)
{ {
raw_->header.value_size = to_disk<le32>(static_cast<uint32_t>(s)); raw_->header.value_size = to_disk<le32>(static_cast<uint32_t>(s));
} }
template <typename ValueTraits> template <typename ValueTraits>
uint64_t uint64_t
node_ref<ValueTraits>::key_at(unsigned i) const node_ref<ValueTraits>::key_at(unsigned i) const
{ {
if (i >= get_nr_entries()) if (i >= get_nr_entries())
throw runtime_error("key index out of bounds"); throw runtime_error("key index out of bounds");
return to_cpu<uint64_t>(raw_->keys[i]); return to_cpu<uint64_t>(raw_->keys[i]);
} }
template <typename ValueTraits> template <typename ValueTraits>
void void
node_ref<ValueTraits>::set_key(unsigned i, uint64_t k) node_ref<ValueTraits>::set_key(unsigned i, uint64_t k)
{ {
raw_->keys[i] = to_disk<le64>(k); raw_->keys[i] = to_disk<le64>(k);
} }
template <typename ValueTraits> template <typename ValueTraits>
typename ValueTraits::value_type typename ValueTraits::value_type
node_ref<ValueTraits>::value_at(unsigned i) const node_ref<ValueTraits>::value_at(unsigned i) const
{ {
if (i >= get_nr_entries()) if (i >= get_nr_entries())
throw runtime_error("value index out of bounds"); throw runtime_error("value index out of bounds");
@ -216,24 +216,24 @@ node_ref<ValueTraits>::value_at(unsigned i) const
typename ValueTraits::value_type v; typename ValueTraits::value_type v;
ValueTraits::unpack(d, v); ValueTraits::unpack(d, v);
return v; return v;
} }
template <typename ValueTraits> template <typename ValueTraits>
void void
node_ref<ValueTraits>::set_value(unsigned i, node_ref<ValueTraits>::set_value(unsigned i,
typename ValueTraits::value_type const &v) typename ValueTraits::value_type const &v)
{ {
typename ValueTraits::disk_type d; typename ValueTraits::disk_type d;
ValueTraits::pack(v, d); ValueTraits::pack(v, d);
::memcpy(value_ptr(i), &d, sizeof(d)); ::memcpy(value_ptr(i), &d, sizeof(d));
} }
template <typename ValueTraits> template <typename ValueTraits>
void void
node_ref<ValueTraits>::insert_at(unsigned i, node_ref<ValueTraits>::insert_at(unsigned i,
uint64_t key, uint64_t key,
typename ValueTraits::value_type const &v) typename ValueTraits::value_type const &v)
{ {
unsigned n = get_nr_entries(); unsigned n = get_nr_entries();
if ((n + 1) > get_max_entries()) if ((n + 1) > get_max_entries())
throw runtime_error("too many entries"); throw runtime_error("too many entries");
@ -242,24 +242,24 @@ node_ref<ValueTraits>::insert_at(unsigned i,
::memmove(key_ptr(i + 1), key_ptr(i), sizeof(uint64_t) * (n - i)); ::memmove(key_ptr(i + 1), key_ptr(i), sizeof(uint64_t) * (n - i));
::memmove(value_ptr(i + 1), value_ptr(i), sizeof(typename ValueTraits::disk_type) * (n - i)); ::memmove(value_ptr(i + 1), value_ptr(i), sizeof(typename ValueTraits::disk_type) * (n - i));
overwrite_at(i, key, v); overwrite_at(i, key, v);
} }
template <typename ValueTraits> template <typename ValueTraits>
void void
node_ref<ValueTraits>::overwrite_at(unsigned i, node_ref<ValueTraits>::overwrite_at(unsigned i,
uint64_t key, uint64_t key,
typename ValueTraits::value_type const &v) typename ValueTraits::value_type const &v)
{ {
set_key(i, key); set_key(i, key);
set_value(i, v); set_value(i, v);
} }
template <typename ValueTraits> template <typename ValueTraits>
void void
node_ref<ValueTraits>::copy_entries(node_ref const &rhs, node_ref<ValueTraits>::copy_entries(node_ref const &rhs,
unsigned begin, unsigned begin,
unsigned end) unsigned end)
{ {
unsigned count = end - begin; unsigned count = end - begin;
unsigned n = get_nr_entries(); unsigned n = get_nr_entries();
if ((n + count) > get_max_entries()) if ((n + count) > get_max_entries())
@ -268,12 +268,12 @@ node_ref<ValueTraits>::copy_entries(node_ref const &rhs,
::memcpy(key_ptr(n), rhs.key_ptr(begin), sizeof(uint64_t) * count); ::memcpy(key_ptr(n), rhs.key_ptr(begin), sizeof(uint64_t) * count);
::memcpy(value_ptr(n), rhs.value_ptr(begin), sizeof(typename ValueTraits::disk_type) * count); ::memcpy(value_ptr(n), rhs.value_ptr(begin), sizeof(typename ValueTraits::disk_type) * count);
set_nr_entries(n + count); set_nr_entries(n + count);
} }
template <typename ValueTraits> template <typename ValueTraits>
int int
node_ref<ValueTraits>::bsearch(uint64_t key, int want_hi) const node_ref<ValueTraits>::bsearch(uint64_t key, int want_hi) const
{ {
int lo = -1, hi = get_nr_entries(); int lo = -1, hi = get_nr_entries();
while(hi - lo > 1) { while(hi - lo > 1) {
@ -290,12 +290,12 @@ node_ref<ValueTraits>::bsearch(uint64_t key, int want_hi) const
} }
return want_hi ? hi : lo; return want_hi ? hi : lo;
} }
template <typename ValueTraits> template <typename ValueTraits>
optional<unsigned> optional<unsigned>
node_ref<ValueTraits>::exact_search(uint64_t key) const node_ref<ValueTraits>::exact_search(uint64_t key) const
{ {
int i = bsearch(key, 0); int i = bsearch(key, 0);
if (i < 0 || static_cast<unsigned>(i) >= get_nr_entries()) if (i < 0 || static_cast<unsigned>(i) >= get_nr_entries())
return optional<unsigned>(); return optional<unsigned>();
@ -304,48 +304,48 @@ node_ref<ValueTraits>::exact_search(uint64_t key) const
return optional<unsigned>(); return optional<unsigned>();
return optional<unsigned>(i); return optional<unsigned>(i);
} }
template <typename ValueTraits> template <typename ValueTraits>
int int
node_ref<ValueTraits>::lower_bound(uint64_t key) const node_ref<ValueTraits>::lower_bound(uint64_t key) const
{ {
return bsearch(key, 0); return bsearch(key, 0);
} }
template <typename ValueTraits> template <typename ValueTraits>
unsigned unsigned
node_ref<ValueTraits>::calc_max_entries(void) node_ref<ValueTraits>::calc_max_entries(void)
{ {
uint32_t total; uint32_t total;
// key + value // key + value
size_t elt_size = sizeof(uint64_t) + sizeof(typename ValueTraits::disk_type); size_t elt_size = sizeof(uint64_t) + sizeof(typename ValueTraits::disk_type);
total = (MD_BLOCK_SIZE - sizeof(struct node_header)) / elt_size; total = (MD_BLOCK_SIZE - sizeof(struct node_header)) / elt_size;
return (total / 3) * 3; // rounds down return (total / 3) * 3; // rounds down
} }
template <typename ValueTraits> template <typename ValueTraits>
void * void *
node_ref<ValueTraits>::key_ptr(unsigned i) const node_ref<ValueTraits>::key_ptr(unsigned i) const
{ {
return raw_->keys + i; return raw_->keys + i;
} }
template <typename ValueTraits> template <typename ValueTraits>
void * void *
node_ref<ValueTraits>::value_ptr(unsigned i) const node_ref<ValueTraits>::value_ptr(unsigned i) const
{ {
void *value_base = &raw_->keys[to_cpu<uint32_t>(raw_->header.max_entries)]; void *value_base = &raw_->keys[to_cpu<uint32_t>(raw_->header.max_entries)];
return static_cast<unsigned char *>(value_base) + return static_cast<unsigned char *>(value_base) +
sizeof(typename ValueTraits::disk_type) * i; sizeof(typename ValueTraits::disk_type) * i;
} }
template <typename ValueTraits> template <typename ValueTraits>
template <typename RefCounter> template <typename RefCounter>
void void
node_ref<ValueTraits>::inc_children(RefCounter &rc) node_ref<ValueTraits>::inc_children(RefCounter &rc)
{ {
unsigned nr_entries = get_nr_entries(); unsigned nr_entries = get_nr_entries();
for (unsigned i = 0; i < nr_entries; i++) { for (unsigned i = 0; i < nr_entries; i++) {
typename ValueTraits::value_type v; typename ValueTraits::value_type v;
@ -354,19 +354,19 @@ node_ref<ValueTraits>::inc_children(RefCounter &rc)
ValueTraits::unpack(d, v); ValueTraits::unpack(d, v);
rc.inc(v); rc.inc(v);
} }
} }
//---------------------------------------------------------------- //----------------------------------------------------------------
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
btree<Levels, ValueTraits>:: btree<Levels, ValueTraits>::
btree(typename transaction_manager::ptr tm, btree(typename transaction_manager::ptr tm,
typename ValueTraits::ref_counter rc) typename ValueTraits::ref_counter rc)
: tm_(tm), : tm_(tm),
destroy_(false), destroy_(false),
rc_(rc), rc_(rc),
validator_(new btree_node_validator) validator_(new btree_node_validator)
{ {
using namespace btree_detail; using namespace btree_detail;
write_ref root = tm_->new_block(validator_); write_ref root = tm_->new_block(validator_);
@ -378,11 +378,11 @@ btree(typename transaction_manager::ptr tm,
n.set_value_size(sizeof(typename ValueTraits::disk_type)); n.set_value_size(sizeof(typename ValueTraits::disk_type));
root_ = root.get_location(); root_ = root.get_location();
} }
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
btree<Levels, ValueTraits>:: btree<Levels, ValueTraits>::
btree(typename transaction_manager::ptr tm, btree(typename transaction_manager::ptr tm,
block_address root, block_address root,
typename ValueTraits::ref_counter rc) typename ValueTraits::ref_counter rc)
: tm_(tm), : tm_(tm),
@ -390,16 +390,16 @@ btree(typename transaction_manager::ptr tm,
root_(root), root_(root),
rc_(rc), rc_(rc),
validator_(new btree_node_validator) validator_(new btree_node_validator)
{ {
} }
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
btree<Levels, ValueTraits>::~btree() btree<Levels, ValueTraits>::~btree()
{ {
} }
namespace { namespace {
template <typename ValueTraits> template <typename ValueTraits>
struct lower_bound_search { struct lower_bound_search {
static optional<unsigned> search(btree_detail::node_ref<ValueTraits> n, uint64_t key) { static optional<unsigned> search(btree_detail::node_ref<ValueTraits> n, uint64_t key) {
@ -413,12 +413,12 @@ namespace {
return n.exact_search(key); return n.exact_search(key);
} }
}; };
} }
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
typename btree<Levels, ValueTraits>::maybe_value typename btree<Levels, ValueTraits>::maybe_value
btree<Levels, ValueTraits>::lookup(key const &key) const btree<Levels, ValueTraits>::lookup(key const &key) const
{ {
using namespace btree_detail; using namespace btree_detail;
ro_spine spine(tm_, validator_); ro_spine spine(tm_, validator_);
@ -434,32 +434,32 @@ btree<Levels, ValueTraits>::lookup(key const &key) const
} }
return lookup_raw<ValueTraits, exact_search<ValueTraits> >(spine, root, key[Levels - 1]); return lookup_raw<ValueTraits, exact_search<ValueTraits> >(spine, root, key[Levels - 1]);
} }
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
typename btree<Levels, ValueTraits>::maybe_pair typename btree<Levels, ValueTraits>::maybe_pair
btree<Levels, ValueTraits>::lookup_le(key const &key) const btree<Levels, ValueTraits>::lookup_le(key const &key) const
{ {
using namespace btree_detail; using namespace btree_detail;
return maybe_pair(); return maybe_pair();
} }
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
typename btree<Levels, ValueTraits>::maybe_pair typename btree<Levels, ValueTraits>::maybe_pair
btree<Levels, ValueTraits>::lookup_ge(key const &key) const btree<Levels, ValueTraits>::lookup_ge(key const &key) const
{ {
using namespace btree_detail; using namespace btree_detail;
return maybe_pair(); return maybe_pair();
} }
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
void void
btree<Levels, ValueTraits>:: btree<Levels, ValueTraits>::
insert(key const &key, insert(key const &key,
typename ValueTraits::value_type const &value) typename ValueTraits::value_type const &value)
{ {
using namespace btree_detail; using namespace btree_detail;
block_address block = root_; block_address block = root_;
@ -486,54 +486,54 @@ insert(key const &key,
else else
// FIXME: check if we're overwriting with the same value. // FIXME: check if we're overwriting with the same value.
n.set_value(index, value); n.set_value(index, value);
} }
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
void void
btree<Levels, ValueTraits>::remove(key const &key) btree<Levels, ValueTraits>::remove(key const &key)
{ {
using namespace btree_detail; using namespace btree_detail;
} }
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
block_address block_address
btree<Levels, ValueTraits>::get_root() const btree<Levels, ValueTraits>::get_root() const
{ {
return root_; return root_;
} }
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
void void
btree<Levels, ValueTraits>::set_root(block_address root) btree<Levels, ValueTraits>::set_root(block_address root)
{ {
using namespace btree_detail; using namespace btree_detail;
root_ = root; root_ = root;
} }
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
typename btree<Levels, ValueTraits>::ptr typename btree<Levels, ValueTraits>::ptr
btree<Levels, ValueTraits>::clone() const btree<Levels, ValueTraits>::clone() const
{ {
tm_->get_sm()->inc(root_); tm_->get_sm()->inc(root_);
return ptr(new btree<Levels, ValueTraits>(tm_, root_, rc_)); return ptr(new btree<Levels, ValueTraits>(tm_, root_, rc_));
} }
#if 0 #if 0
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
void void
btree<Levels, ValueTraits>::destroy() btree<Levels, ValueTraits>::destroy()
{ {
using namespace btree_detail; using namespace btree_detail;
} }
#endif #endif
template <unsigned Levels, typename _> template <unsigned Levels, typename _>
template <typename ValueTraits, typename Search> template <typename ValueTraits, typename Search>
optional<typename ValueTraits::value_type> optional<typename ValueTraits::value_type>
btree<Levels, _>:: btree<Levels, _>::
lookup_raw(ro_spine &spine, block_address block, uint64_t key) const lookup_raw(ro_spine &spine, block_address block, uint64_t key) const
{ {
using namespace boost; using namespace boost;
typedef typename ValueTraits::value_type leaf_type; typedef typename ValueTraits::value_type leaf_type;
@ -557,18 +557,18 @@ lookup_raw(ro_spine &spine, block_address block, uint64_t key) const
node_ref<uint64_traits> internal = spine.template get_node<uint64_traits>(); node_ref<uint64_traits> internal = spine.template get_node<uint64_traits>();
block = internal.value_at(*mi); block = internal.value_at(*mi);
} }
} }
template <unsigned Levels, typename _> template <unsigned Levels, typename _>
template <typename ValueTraits> template <typename ValueTraits>
void void
btree<Levels, _>:: btree<Levels, _>::
split_node(btree_detail::shadow_spine &spine, split_node(btree_detail::shadow_spine &spine,
block_address parent_index, block_address parent_index,
uint64_t key, uint64_t key,
bool top) bool top)
{ {
node_ref<ValueTraits> n = spine.template get_node<ValueTraits>(); node_ref<ValueTraits> n = spine.template get_node<ValueTraits>();
if (n.get_nr_entries() == n.get_max_entries()) { if (n.get_nr_entries() == n.get_max_entries()) {
if (top) if (top)
@ -576,15 +576,15 @@ split_node(btree_detail::shadow_spine &spine,
else else
split_sibling<ValueTraits>(spine, parent_index, key); split_sibling<ValueTraits>(spine, parent_index, key);
} }
} }
template <unsigned Levels, typename _> template <unsigned Levels, typename _>
template <typename ValueTraits> template <typename ValueTraits>
void void
btree<Levels, _>:: btree<Levels, _>::
split_beneath(btree_detail::shadow_spine &spine, split_beneath(btree_detail::shadow_spine &spine,
uint64_t key) uint64_t key)
{ {
using namespace btree_detail; using namespace btree_detail;
node_type type; node_type type;
@ -635,16 +635,16 @@ split_beneath(btree_detail::shadow_spine &spine,
spine.step(left); spine.step(left);
else else
spine.step(right); spine.step(right);
} }
template <unsigned Levels, typename _> template <unsigned Levels, typename _>
template <typename ValueTraits> template <typename ValueTraits>
void void
btree<Levels, _>:: btree<Levels, _>::
split_sibling(btree_detail::shadow_spine &spine, split_sibling(btree_detail::shadow_spine &spine,
block_address parent_index, block_address parent_index,
uint64_t key) uint64_t key)
{ {
using namespace btree_detail; using namespace btree_detail;
node_ref<ValueTraits> l = spine.template get_node<ValueTraits>(); node_ref<ValueTraits> l = spine.template get_node<ValueTraits>();
@ -672,18 +672,18 @@ split_sibling(btree_detail::shadow_spine &spine,
spine.step(left); spine.step(left);
else else
spine.step(right); spine.step(right);
} }
// Returns true if we need a new insertion, rather than overwrite. // Returns true if we need a new insertion, rather than overwrite.
template <unsigned Levels, typename _> template <unsigned Levels, typename _>
template <typename ValueTraits> template <typename ValueTraits>
bool bool
btree<Levels, _>:: btree<Levels, _>::
insert_location(btree_detail::shadow_spine &spine, insert_location(btree_detail::shadow_spine &spine,
block_address block, block_address block,
uint64_t key, uint64_t key,
int *index) int *index)
{ {
using namespace btree_detail; using namespace btree_detail;
bool top = true; // this isn't the same as spine.has_parent() bool top = true; // this isn't the same as spine.has_parent()
@ -739,24 +739,24 @@ insert_location(btree_detail::shadow_spine &spine,
return ((static_cast<unsigned>(i) >= leaf.get_nr_entries()) || return ((static_cast<unsigned>(i) >= leaf.get_nr_entries()) ||
(leaf.key_at(i) != key)); (leaf.key_at(i) != key));
} }
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
void void
btree<Levels, ValueTraits>::visit_depth_first(visitor &v) const btree<Levels, ValueTraits>::visit_depth_first(visitor &v) const
{ {
node_location loc; node_location loc;
walk_tree(v, loc, root_); walk_tree(v, loc, root_);
v.visit_complete(); v.visit_complete();
} }
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
void void
btree<Levels, ValueTraits>::walk_tree(visitor &v, btree<Levels, ValueTraits>::walk_tree(visitor &v,
node_location const &loc, node_location const &loc,
block_address b) const block_address b) const
{ {
try { try {
walk_tree_internal(v, loc, b); walk_tree_internal(v, loc, b);
@ -769,14 +769,14 @@ btree<Levels, ValueTraits>::walk_tree(visitor &v,
throw; throw;
} }
} }
} }
template <unsigned Levels, typename ValueTraits> template <unsigned Levels, typename ValueTraits>
void void
btree<Levels, ValueTraits>::walk_tree_internal(visitor &v, btree<Levels, ValueTraits>::walk_tree_internal(visitor &v,
node_location const &loc, node_location const &loc,
block_address b) const block_address b) const
{ {
using namespace btree_detail; using namespace btree_detail;
read_ref blk = tm_->read_lock(b, validator_); read_ref blk = tm_->read_lock(b, validator_);
@ -809,6 +809,7 @@ btree<Levels, ValueTraits>::walk_tree_internal(visitor &v,
leaf_node ov = to_node<ValueTraits>(blk); leaf_node ov = to_node<ValueTraits>(blk);
v.visit_leaf(loc, ov); v.visit_leaf(loc, ov);
} }
}
} }
//---------------------------------------------------------------- //----------------------------------------------------------------