-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvlog.h
46 lines (33 loc) · 811 Bytes
/
vlog.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
#ifndef VLOG_H
#define VLOG_H
#include <cstdint>
#include <string>
#include "utils.h"
#include <map>
#define MAGIC 0xff
class Entry
{
friend class VLog;
uint8_t magic;
uint16_t checkSum;
uint64_t key;
uint32_t vlen;
std::string value;
public:
Entry(uint64_t k, std::string val);
};
class VLog
{
friend class Entry;
std::string dir;
uint64_t tail;
uint64_t head;
std::string DFLAG = "~DELETED~";
public:
VLog(const std::string &dir);
~VLog(){};
void append(std::map<uint64_t, std::string> all, std::map<uint64_t, uint64_t> &offsets);
std::string get(uint64_t offset, uint32_t vlen);
void gc(std::map<uint64_t, std::pair<std::string, uint64_t>> &kVOff, uint64_t chunk_size, uint64_t &holeOff, uint64_t &len);
};
#endif // VLOG_H