forked from kohler/masstree-beta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
masstree.hh
94 lines (78 loc) · 2.96 KB
/
masstree.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* Masstree
* Eddie Kohler, Yandong Mao, Robert Morris
* Copyright (c) 2012-2013 President and Fellows of Harvard College
* Copyright (c) 2012-2013 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, subject to the conditions
* listed in the Masstree LICENSE file. These conditions include: you must
* preserve this copyright notice, and you cannot mention the copyright
* holders in advertising related to the Software without their permission.
* The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
* notice is a summary of the Masstree LICENSE file; the license in that file
* is legally binding.
*/
#ifndef MASSTREE_HH
#define MASSTREE_HH
#include "compiler.hh"
#include "str.hh"
#include "ksearch.hh"
class threadinfo;
namespace Masstree {
using lcdf::Str;
using lcdf::String;
template <int LW = 15, int IW = LW> struct nodeparams {
static constexpr int leaf_width = LW;
static constexpr int internode_width = IW;
static constexpr bool concurrent = true;
static constexpr bool prefetch = true;
static constexpr int bound_method = bound_method_binary;
static constexpr int debug_level = 0;
typedef uint64_t ikey_type;
};
template <int LW, int IW> constexpr int nodeparams<LW, IW>::leaf_width;
template <int LW, int IW> constexpr int nodeparams<LW, IW>::internode_width;
template <int LW, int IW> constexpr int nodeparams<LW, IW>::debug_level;
template <typename P> class node_base;
template <typename P> class leaf;
template <typename P> class internode;
template <typename P> class leafvalue;
template <typename P> class key;
template <typename P> class basic_table;
template <typename P> class unlocked_tcursor;
template <typename P> class tcursor;
template <typename P>
class basic_table {
public:
typedef P param_type;
typedef node_base<P> node_type;
typedef typename P::value_type value_type;
basic_table()
: root_(0) {
}
void initialize(threadinfo *ti);
void reinitialize(threadinfo *ti);
inline node_type *root() const {
return root_;
}
bool get(Str key, value_type &value, threadinfo *ti) const;
template <typename F>
int scan(Str firstkey, bool matchfirst, F &scanner, threadinfo *ti) const;
template <typename F>
int rscan(Str firstkey, bool matchfirst, F &scanner, threadinfo *ti) const;
template <typename F>
inline int modify(Str key, F &f, threadinfo *ti);
template <typename F>
inline int modify_insert(Str key, F &f, threadinfo *ti);
inline void print(FILE *f = 0, int indent = 0) const;
private:
node_type *root_;
template <typename H, typename F>
int scan(H helper, Str firstkey, bool matchfirst,
F &scanner, threadinfo *ti) const;
friend class unlocked_tcursor<P>;
friend class tcursor<P>;
};
} // namespace Masstree
#endif