forked from moonpolysoft/dynomite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBTREEFORMAT
39 lines (22 loc) · 792 Bytes
/
BTREEFORMAT
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
Implementation of a btree based merkle tree. The original merkle tree would not scale out to a large number of keys due to the limitation of keeping the tree in main memory. Therefore we will try and store the
btree file:
file header: version:1, blocksize:32, freepointer:64, rootpointer:64,
freekeys1:64, freekeys2:64, freekeys3:64, freekeys4:64, freekeys5:64
reserved/bytes:
header size: 85
node:{0,m:32,[keyhash:32],[childhash:32,child:64]}
leaf:{1,m:32,[keyhash:32,keypointer:64,valhash:32]}
freenode:{2,nextpointer:64,0:(blocksize-9)}
for nodes:
blocksize = 1 + 4 + D*4 + (D+1)*12
D = (blocksize-17)/16
for leaves:
blocksize = 5 + D*16
D = (blocksize-5)/16
65521
key file:
[key\0,key\0,key\0]
keys allocation
l = 2**4
m = 2**64
header size = 85 + (√blocksize - 4)*8