-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.h
117 lines (84 loc) · 2.73 KB
/
index.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include <iostream>
#include "indexkey.h"
#include "./PRISM/include/MTS.h"
#include "BwTree/bwtree.h"
#include "masstree/mtIndexAPI.hh"
#ifndef _INDEX_H
#define _INDEX_H
using namespace wangziqi2013;
using namespace bwtree;
template<typename KeyType, class KeyComparator>
class Index
{
public:
virtual bool insert(KeyType key, uint64_t value, threadinfo *ti) = 0;
virtual uint64_t find(KeyType key, std::vector<uint64_t> *v, threadinfo *ti) = 0;
virtual uint64_t find_bwtree_fast(KeyType key, std::vector<uint64_t> *v) {};
// Used for bwtree only
virtual bool insert_bwtree_fast(KeyType key, uint64_t value) {};
virtual bool upsert(KeyType key, uint64_t value, threadinfo *ti) = 0;
virtual uint64_t scan(KeyType key, int range, threadinfo *ti) = 0;
virtual bool recover(size_t start_index, threadinfo *ti) = 0;
virtual int64_t getMemory() const = 0;
// This initializes the thread pool
virtual void UpdateThreadLocal(size_t thread_num) = 0;
virtual void AssignGCID(size_t thread_id) = 0;
virtual void UnregisterThread(size_t thread_id) = 0;
// After insert phase perform this action
// By default it is empty
// This will be called in the main thread
virtual void AfterLoadCallback() {}
// This is called after threads finish but before the thread local are
// destroied by the thread manager
virtual void CollectStatisticalCounter(int) {}
virtual size_t GetIndexSize() { return 0UL; }
// Destructor must also be virtual
virtual ~Index() {}
};
template<typename KeyType, class KeyComparator>
class MTSIndex : public Index<KeyType, KeyComparator>
{
public:
~MTSIndex() {
//idx.~MTS();
}