forked from utsaslab/RECIPE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tree.h
84 lines (60 loc) · 2.3 KB
/
Tree.h
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
//
// Created by florian on 18.11.15.
//
#ifndef ART_ROWEX_TREE_H
#define ART_ROWEX_TREE_H
#include "N.h"
using namespace ART;
namespace ART_ROWEX {
class Tree {
public:
using LoadKeyFunction = void (*)(TID tid, Key &key);
private:
N *const root;
void *checkKey(const Key *ret, const Key *k) const;
LoadKeyFunction loadKey;
Epoche epoche{256};
public:
enum class CheckPrefixResult : uint8_t {
Match,
NoMatch,
OptimisticMatch
};
enum class CheckPrefixPessimisticResult : uint8_t {
Match,
NoMatch,
SkippedLevel
};
enum class PCCompareResults : uint8_t {
Smaller,
Equal,
Bigger,
SkippedLevel
};
enum class PCEqualsResults : uint8_t {
BothMatch,
Contained,
NoMatch,
SkippedLevel
};
static CheckPrefixResult checkPrefix(N* n, const Key *k, uint32_t &level);
static CheckPrefixPessimisticResult checkPrefixPessimistic(N *n, const Key *k, uint32_t &level,
uint8_t &nonMatchingKey,
Prefix &nonMatchingPrefix,
LoadKeyFunction loadKey);
static PCCompareResults checkPrefixCompare(const N* n, const Key *k, uint32_t &level, LoadKeyFunction loadKey);
static PCEqualsResults checkPrefixEquals(const N* n, uint32_t &level, const Key *start, const Key *end, LoadKeyFunction loadKey);
public:
Tree(LoadKeyFunction loadKey);
Tree(const Tree &) = delete;
Tree(Tree &&t) : root(t.root), loadKey(t.loadKey) { }
~Tree();
ThreadInfo getThreadInfo();
void *lookup(const Key *k, ThreadInfo &threadEpocheInfo) const;
bool lookupRange(const Key *start, const Key *end, const Key *continueKey, Key *result[], std::size_t resultLen,
std::size_t &resultCount, ThreadInfo &threadEpocheInfo) const;
bool insert(const Key *k, ThreadInfo &epocheInfo);
bool remove(const Key *k, ThreadInfo &epocheInfo);
};
}
#endif //ART_ROWEX_TREE_H