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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#![deny(missing_docs)]
#![cfg_attr(test, deny(warnings))]
#![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", plugin(clippy))]
#![cfg_attr(feature="clippy", allow(inline_always))]
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate crossbeam;
extern crate coco;
extern crate bincode;
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "log")]
#[macro_use]
extern crate log as _log;
#[cfg(feature = "libc")]
extern crate libc;
#[cfg(feature = "rayon")]
extern crate rayon;
#[cfg(feature = "zstd")]
extern crate zstd;
#[cfg(test)]
extern crate rand;
pub use tree::{Tree, TreeIter};
pub use page::{Materializer, PageCache};
pub use log::{HEADER_LEN, LockFreeLog, Log, LogRead};
use stack::Stack;
pub use radix::Radix;
pub use config::Config;
#[cfg(feature = "libc")]
pub mod c;
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 crc64;
mod stack;
mod page;
mod radix;
mod config;
mod thread_cache;
use bound::Bound;
use page::CasKey;
use stack::{StackIter, node_from_frag_vec};
use thread_cache::ThreadCache;
type LogID = u64;
type PageID = usize;
type Key = Vec<u8>;
type KeyRef<'a> = &'a [u8];
type Value = Vec<u8>;
#[inline(always)]
fn tn() -> String {
use std::thread;
thread::current().name().unwrap_or("unknown").to_owned()
}
fn uptime() -> std::time::Duration {
lazy_static! {
static ref START: std::time::Instant = std::time::Instant::now();
}
START.elapsed()
}