-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitcask_t.dag
91 lines (47 loc) · 1.85 KB
/
bitcask_t.dag
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
(Build working hash index storage engine)
(Create a prompt)
(Design layout
of segment file
(Remember to reserve byte for terminating '\0')
(What information needs to be stored?)
(How long each value is (how many bytes to read)))
(Initialize in-memory hash-map
(Create hash table using separate chaining
(Write a hash function
(Defer creating a good one))
(Create array of pointers to singly linked lists
(Check if current node is occupied somehow))
(Implement error handling
(GET on a key that doesn't exist in the hash table)
(Insert a value that doesn't fit in the allocated space))))
(? Break out hashmap implementation
from rest of file)
(Write key-values
to a segment file
(Get a file descriptor)
(Write the keysize, valuesize, key, and value
Write the things inside the structs, not the struct itself)
Code: focus on the `append_to_segment` function)
(Include code for variable-sized values--this has to be done, actually. But when?)
(Use tombstone values to indicate deletion)
(Fragment segment files
(* Include file ID in the hashmap ("keydir") as well
(? How to generate/keep track of these file IDs)
(? How to know what file ID to use when generating a new file
(- fold max_id over files in current dir)
(- write current max ID to a file)
(- randomly generate IDs, check for collisions before creating a file)
(- use timestamp as file ID)
(+ going with writing current max ID to a file)))
(~ Include the value size in the keydir as well)
(Close and store old file
when full)
(Create new segment file)
(Start writing to new segment file))
(Compact closed segment files)
(Merge closed segment files
(Compact and merge
simultaneously))
(Implement multithreaded reads)
(Compact and merge
in a background thread)