-
Notifications
You must be signed in to change notification settings - Fork 1
/
LsmTree.h
87 lines (52 loc) · 1.41 KB
/
LsmTree.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
//
// Created by Stathis on 3/12/2019.
//
#ifndef SIMPLE_EXAMPLE_LSMTREE_H
#define SIMPLE_EXAMPLE_LSMTREE_H
#include <iostream>
#include "Level.h"
#include "MemoryRun.h"
#include "ResultSet.h"
#include <string>
#include <vector>
using namespace std;
class LsmTree {
protected:
//---------- Levels ----------
Level *diskLevels;
MemoryRun *memRun;
//---------- Tree metadata ----------
int levelsCount;
int entriesPerRun;
short bitsPerValue;
string filename;
MemoryRun sortMerge(MemoryRun *older, MemoryRun *newer);
string getNextFilename();
RunMetadata *createMetadata(MemoryRun *memRunData, string suffix);
Entry *getFromDisk(int key);
string suffix(int level, int run);
public:
LsmTree();
LsmTree(int entriesPerRun, int maxRunsPerLevel, short bitsPerValue);
void removeMany();
Entry *get(int key);
MemoryRun *getRange(int low, int high);
void printMeta();
~LsmTree();
};
class TierLsmTree : public LsmTree {
public:
TierLsmTree(int, int, short bitsPerValue);
void flushToDisk();
void insert(int key, int value, bool isRemove);
void insert(int key, int value);
void remove(int key);
void insert(Entry *temp);
};
class LevelLsmTree : public LsmTree {
public:
LevelLsmTree(int, int, short bitsPerValue);
void flushToDisk();
void insert(int key, int value);
};
#endif //SIMPLE_EXAMPLE_LSMTREE_H