-
Notifications
You must be signed in to change notification settings - Fork 24
/
xdbexit.c
49 lines (44 loc) · 999 Bytes
/
xdbexit.c
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
/*
* Copyright (c) 2016--2021 Wu, Xingbo <[email protected]>
*
* All rights reserved. No warranty, explicit or implicit, provided.
*/
#define _GNU_SOURCE
#include "lib.h"
#include "kv.h"
#include "sst.h"
#include "xdb.h"
int
main(int argc, char** argv)
{
if (argc < 4) {
printf("Usage: <dirname> <mt-mb> <cache-mb>\n");
return 0;
}
struct xdb * const xdb = remixdb_open(argv[1], a2u64(argv[2]), a2u64(argv[3]));
if (!xdb) {
fprintf(stderr, "xdb_open failed\n");
return 0;
}
struct xdb_ref * const ref = remixdb_ref(xdb);
u64 k0 = 0;
u8 key[20];
for (;;) {
strdec_64(key, k0);
if (!remixdb_probe(ref, key, 20)) {
printf("first missing %lu\n", k0);
break;
}
k0++;
}
u8 value[1024];
memset(value, 0x11, 1024);
for (u64 i = 0; i < 1000000; i++) {
strdec_64(key, k0 + i);
remixdb_set(ref, key, 20, value, 1024);
}
printf("inserted [%lu, %lu)\n", k0, k0 + 1000000);
remixdb_sync(ref);
exit(0);
return 0;
}