-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cc
52 lines (48 loc) · 1.15 KB
/
main.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
//
// Created by plutolove on 9/2/16.
//
#include <iostream>
#include <cassert>
#include "leveldb/db.h"
typedef long long LL;
using namespace std;
int main() {
leveldb::DB *db;
leveldb::Options options;
options.create_if_missing = true;
leveldb::Status status = leveldb::DB::Open(options, "/home/meng/CLionProjects/db/", &db);
assert(status.ok());
string key = "name";
string value = "mengshangqi";
status = db->Put(leveldb::WriteOptions(), key, value);
assert(status.ok());
// read
status = db->Get(leveldb::ReadOptions(), key, &value);
assert(status.ok());
cout << value << endl;
for(int i=500000; i<500001; i++) {
status = db->Put(leveldb::WriteOptions(), to_string(i)+"dfgdf", to_string(i)+"fdhfghjdfg");
assert(status.ok());
if(i == 499999 + 1) {
int x;
cin>>x;
}
}
return 0;
}
/*
#include "db/skiplist.h"
#include "util/arena.h"
struct Cmp {
int operator()(const std::string& a, const std::string& b) const {
if (a < b) return -1;
else return 1;
}
};
int main() {
leveldb::Arena a;
Cmp c1;
leveldb::SkipList<std::string, Cmp> list(c1, &a);
list.Insert("sdfgsdfg");
return 0;
}*/