-
Notifications
You must be signed in to change notification settings - Fork 1
/
kvstore.cc
56 lines (48 loc) · 996 Bytes
/
kvstore.cc
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
#include "kvstore.h"
#include <string>
KVStore::KVStore(const std::string &dir): KVStoreAPI(dir)
{
}
KVStore::~KVStore()
{
}
/**
* Insert/Update the key-value pair.
* No return values for simplicity.
*/
void KVStore::put(uint64_t key, const std::string &s)
{
// memtable.put(key,s);
lsm.put(key,s);
}
/**
* Returns the (string) value of the given key.
* An empty string indicates not found.
*/
std::string KVStore::get(uint64_t key)
{
// std::string * result = memtable.get(key);
// std:string fail("");
// if(result==NULL) return fail;
// return *result;
return lsm.get(key);
}
/**
* Delete the given key-value pair if it exists.
* Returns false iff the key is not found.
*/
bool KVStore::del(uint64_t key)
{
// if(!memtable.remove2(key))
// return false;
// return true;
return lsm.del(key);
}
/**
* This resets the kvstore. All key-value pairs should be removed,
* including memtable and all sstables files.
*/
void KVStore::reset()
{
lsm.reset();
}