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
#![deny(missing_docs)]
extern crate libc;
extern crate rayon;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate bincode;
extern crate rand;
#[macro_use]
extern crate log as logger;
extern crate env_logger;
extern crate tempfile;
extern crate zstd;
extern crate time;
pub use tree::Tree;
pub use page::{Materializer, PageCache};
pub use log::{HEADER_LEN, LockFreeLog, Log};
use stack::Stack;
pub use radix::Radix;
pub use config::Config;
use crc16::crc16_arr;
macro_rules! rep_no_copy {
($e:expr; $n:expr) => {
{
let mut v = Vec::with_capacity($n);
for _ in 0..$n {
v.push($e);
}
v
}
};
}
#[cfg(test)]
fn test_fail() -> bool {
use rand::Rng;
rand::thread_rng().gen::<bool>();
false
}
#[cfg(not(test))]
#[inline(always)]
fn test_fail() -> bool {
false
}
mod tree;
mod bound;
mod log;
mod crc16;
mod stack;
mod page;
mod radix;
mod config;
mod thread_cache;
mod ops;
use bound::Bound;
use page::CacheEntry;
use stack::{StackIter, node_from_frag_vec};
use thread_cache::ThreadCache;
type LogID = u64;
type PageID = usize;
type Key = Vec<u8>;
type Value = Vec<u8>;
#[inline(always)]
fn raw<T>(t: T) -> *const T {
Box::into_raw(Box::new(t)) as *const T
}
#[inline(always)]
fn tn() -> String {
use std::thread;
thread::current()
.name()
.unwrap_or("unknown")
.to_owned()
}