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
91
92
93
94
95
96
97
98
99
100
101
102
103
//! This crate is not yet reliable or stable!
//!
//! [Table] stores [Value]s which have a specific [DataType].
/*
Idea for splitting hash buckets incrementally.
Suppose we have a hash table with 4 buckets, numbered as below:
[2] [6] [3] [4]
0 1 2 3
and suppose that bucket [6] ( index 1 ) is "full" and we want to insert into it.
We first double the number of buckets:
[2] [2] [6] [6] [3] [3] [4] [4]
0 1 2 3 4 5 6 7
without creating any new pages. This is a relatively cheap operation.
Now we split the records in [6] (now index 2 and 3) into two, the new page id being [7], as below:
[2] [2] [6] [7] [3] [3] [4] [4]
0 1 2 3 4 5 6 7
[6] and [7] should each be roughly half-full, and we can continue inserting.
Now suppose later on [3] ( index 5 ) is full and we want to insert into it.
We first check the "buddy"*, index 4. If it has the same page number ( as is the case here ),
we do not need to double the number of buckets, instead split the records in [3] into two
buckets ( new page number is [8] ), as below:
[2] [2] [6] [7] [3] [8] [4] [4]
[3] and [8] should each be roughly half-full, and we can continue inserting.
* The buddy position is x+1 if x is even, x-1 if x is odd.
*/
/// [Table] stores [Value]s which have a specific [DataType].
pub use ;
/// Generic [Value]s.
pub use Value;
/// [DataType] - describes, encodes and decodes [Value]s.
pub use DataType;
use ;
/// [PageSet] - keeps track of changed pages that need saving.
use PData;
pub use PageSet;
/// [Store] - maps keys to variable size values (no size restriction) using 64 bit hash.
pub use Store;
use ;
/// [VBuckMap] - maps keys to small variable size values using 64 bit hash. For possibly large values see [Store].
pub use IdVKey;
use ;
// Remaining modules are private.
/// List of pages implemented as tree for [VBuckMap].
/// Bucket for [VBuckMap].
use ;
/// Standard page size ( for pagetree ).
const PAGE_SIZE: u64 = 3952;
// Basic data types.
pub use ;
pub use ;
/// `StringA<Local>`
pub type LString = StringA;
/// `VecA<T, Local>`
pub type LVec<T> = VecA;
/// `BoxA<T, Local>`
pub type LBox<T> = BoxA;
/// `RcA<T, Lpcal>`
pub type LRc<T> = RcA;
/// `StringA<Perm>`
pub type GString = StringA;
/// `VecA<T, Perm>`
pub type GVec<T> = VecA;
/// `BoxA<T, Perm>`
pub type GBox<T> = BoxA;
/// `RcA<T, Perm>`
pub type GRc<T> = RcA;