Do we need per-record metadata?
Do we need metadata?
No. Each field has the same length for every record.
| | | |
| | | | | | |
| | | | ‘0123’ | ‘PHO 206’ | 199 |
| | | | ‘0123’ | ‘PHO 206’ | 199 |
0
2
4
6
8
12
19
23
8 | | | | ‘0123’ | ‘PHO 206’ | 199 |
0
2
4
6
8
12
19
23
8 | 12 | | | ‘0123’ | ‘PHO 206’ | 199 |
0
2
4
6
8
12
19
23
8 | 12 | 19 | | ‘0123’ | ‘PHO 206’ | 199 |
0
2
4
6
8
12
19
23
8 | 12 | 19 | 23 | ‘0123’ | ‘PHO 206’ | 199 |
0
2
4
6
8
12
19
23
Length of bytes? 23
8 | -1 | 12 | 16 | ‘0123’ | 199 |
a.
b.
c.
d.
8 | -1 | 12 | 16 | ‘0123’ | NULL | 199 |
8 | 12 | -1 | 16 | ‘0123’ | NULL | 199 |
8 | 12 | -1 | 16 | ‘0123’ | 199 |
8 | -1 | 12 | 16 | ‘0123’ | 199 |
a.
b.
c.
d.
8 | -1 | 12 | 16 | ‘0123’ | NULL | 199 |
8 | 12 | -1 | 16 | ‘0123’ | NULL | 199 |
8 | 12 | -1 | 16 | ‘0123’ | 199 |
| | | | ‘0123’ | 199 |
| | | | ‘0123’ | 199 |
0
2
4
6
8
12
16
8 | | | | ‘0123’ | 199 |
0
2
4
6
8
12
16
8 | -1 | | | ‘0123’ | 199 |
0
2
4
6
8
12
16
8 | -1 | 12 | | ‘0123’ | 199 |
0
2
4
6
8
12
16
8 | -1 | 12 | 16 | ‘0123’ | 199 |
0
2
4
6
8
12
16
15 30 45
7 12
17 22 27
32 38 43
…
55
…
15 30 45
7 12
17 19 22 27
32 38 43
…
55
…
15 30 45
7 12
17 19 22 25 27
32 38 43
…
55
…
15 22 30 45
7 12
17 19
32 38 43
…
55
…
25 27
15 22 30 45
7 12
17 19
32 38 41 43
…
55
…
25 27
15 22 30 45
7 12
17 19
32 38 40 41 43
…
55
…
25 27
15 22 30 40 45
7 12
17 19
32 38
…
55
…
25 27
41 43
15 22
7 12
17 19
32 38
…
30 55
…
25 27
41 43
40 45
In a B+tree, the full key-value pairs are all stored in leaf nodes. The interior nodes only contain keys.
When a node is split, the middle key is sent up and inserted in the parent, but the corresponding key-
value pair remains at the leaf level, in the new node that is created as part of the split.
15 30 45
7 12
17 22 27
30 38 43
…
55
…
15 30 45
7 12
17 19 22 27
30 38 43
…
55
…
15 30 45
7 12
17 19 22 25 27
30 38 43
…
55
…
15 22 30 45
7 12
17 19
30 38 43
…
55
…
22 25 27
15 22 30 45
7 12
17 19
30 38 41 43
…
55
…
22 25 27
15 22 30 45
7 12
17 19
30 38 40 41 43
…
55
…
22 25 27
15 22 30 40 45
7 12
17 19
30 38
…
55
…
22 25 27
40 41 43
15 22
7 12
17 19
30 38
…
30 55
…
22 25 27
40 41 43
40 45
f = 4, n = 2
Add bucket when
f > 2n
f > 4
*Add bucket on next insert
Insert 436
Insert 436
436 % 10 = 6 = 0110
Insert 436
436 % 10 = 6 = 0110
f > 2n, add bucket
Insert 436
436 % 10 = 6 = 0110
f > 2n, add bucket
Insert 436
436 % 10 = 6 = 0110
f > 2n, add bucket
rehash!
00 [1000]
01 [713]
10 [972, 12, 436]
insert 113
00 [1000]
01 [713]
10 [972, 12, 436]
insert 113
113 % 10 = 3
3 = 0011
insert 116
Split
rehash