-
Notifications
You must be signed in to change notification settings - Fork 0
/
kvstore.h
57 lines (40 loc) · 1.2 KB
/
kvstore.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
#pragma once
#include "kvstore_api.h"
#include "sstable.h"
#include "memtable.h"
#include "vLog.h"
#include <cstdint>
#include <sys/types.h>
class KVStore : public KVStoreAPI
{
// You can add your implementation here
private:
// Directory for storing sstables
std::string SSTdir, vLogdir;
// Index of sstable in each level
std::map<uint64_t, std::map<uint64_t, SStable*> > levelIndex;
/****************************************************
levelIndex[level-i][timestamp] = sstable
****************************************************/
// Memtable
MemTable* memtable;
// vLog
vLog* vlog;
uint64_t curvLogOffset;
// Maintain the current timestamp
uint64_t sstMaxTimeStamp = 0;
// Check all the files in the directory
void sstFileCheck(std::string path);
// Compact the sstable in level i
uint64_t mergeCheck();
void merge(uint64_t level);
public:
KVStore(const std::string &dir);
~KVStore();
void put(uint64_t key, const std::string &s) override;
std::string get(uint64_t key) override;
bool del(uint64_t key) override;
void reset() override;
void scan(uint64_t key1, uint64_t key2, std::list<std::pair<uint64_t, std::string>> &list) override;
void gc(uint64_t chunk_size) override;
};