-
Notifications
You must be signed in to change notification settings - Fork 3
/
dump.cpp
74 lines (64 loc) · 2.36 KB
/
dump.cpp
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
//
// Created by xiaolei on 2022/2/27.
//
#include "lightdb.h"
namespace lightdb{
Status LightDB::dumpList(vector<DBFile*>& mergeFiles, const std::string& path) {
Status s;
for(auto & it : listIdx.indexes->record){
std::string key = it.first;
for(const auto& it2 : listIdx.indexes->record[key]){
Entry* e = Entry::NewEntryNoExtra(key, it2, List, ListRPush);
s = dumpStore(mergeFiles, path, e);
if(!s.ok()){
return s;
}
}
}
return s;
}
Status LightDB::dumpHash(vector<DBFile*>& mergeFiles, const std::string& path) {
Status s;
for(auto & it : hashIdx.indexes->record){
std::string key = it.first;
for(auto it2 = hashIdx.indexes->record[key].begin(); it2!=hashIdx.indexes->record[key].end(); it2++){
Entry* e = Entry::NewEntryNow(key, it2->second, it2->first, Hash, HashHSet);
s = dumpStore(mergeFiles, path, e);
if(!s.ok()){
return s;
}
}
}
return s;
}
Status LightDB::dumpSet(vector<DBFile*>& mergeFiles, const std::string& path) {
Status s;
for(auto & it : setIdx.indexes->record){
std::string key = it.first;
for(auto it2 = setIdx.indexes->record[key].begin(); it2!=setIdx.indexes->record[key].end(); it2++){
Entry* e = Entry::NewEntryNoExtra(key, it2->first, Set, SetSAdd);
s = dumpStore(mergeFiles, path, e);
if(!s.ok()){
return s;
}
}
}
return s;
}
Status LightDB::dumpZSet(vector<DBFile*>& mergeFiles, const std::string& path) {
Status s;
for(auto & it : sortedSetIdx.indexes->record){
std::string key = it.first;
Skiplist* list = &sortedSetIdx.indexes->record[key];
for(list->Begin(); !list->End(); list->Next()){
std::string extra = to_string(list->CurScore());
//ZSet Add
Entry* e = Entry::NewEntryNow(key, list->CurMember(), extra, ZSet, ZSetZAdd);
s = dumpStore(mergeFiles, path, e);
if(!s.ok()){
return s;
}
}
}
}
}