-
Notifications
You must be signed in to change notification settings - Fork 115
/
masstree.hh
97 lines (81 loc) · 3.25 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
95
96
97
/* Masstree
* Eddie Kohler, Yandong Mao, Robert Morris
* Copyright (c) 2012-2014 President and Fellows of Harvard College
* Copyright (c) 2012-2014 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"
namespace Masstree {
using lcdf::Str;
using lcdf::String;
class key_unparse_printable_string;
template <typename T> class value_print;
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;
typedef uint32_t nodeversion_value_type;
static constexpr bool need_phantom_epoch = true;
typedef uint64_t phantom_epoch_type;
static constexpr ssize_t print_max_indent_depth = 12;
typedef key_unparse_printable_string key_unparse_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 parameters_type;
typedef node_base<P> node_type;
typedef leaf<P> leaf_type;
typedef typename P::value_type value_type;
typedef typename P::threadinfo_type threadinfo;
typedef unlocked_tcursor<P> unlocked_cursor_type;
typedef tcursor<P> cursor_type;
inline basic_table();
void initialize(threadinfo& ti);
void destroy(threadinfo& ti);
inline node_type* root() const;
inline node_type* fix_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;
inline void print(FILE* f = 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