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
use crate::config::POOL_SIZE;
use crate::nodes::chunk::Chunk;
use crate::nodes::rrb::Node;
use crate::util::Pool;
pub struct RRBPool<A> {
pub(crate) node_pool: Pool<Chunk<Node<A>>>,
pub(crate) value_pool: Pool<Chunk<A>>,
pub(crate) size_pool: Pool<Chunk<usize>>,
}
impl<A> RRBPool<A> {
pub fn new(size: usize) -> Self {
Self::with_sizes(size, size, size)
}
pub fn with_sizes(
node_pool_size: usize,
leaf_pool_size: usize,
size_table_pool_size: usize,
) -> Self {
Self {
node_pool: Pool::new(node_pool_size),
value_pool: Pool::new(leaf_pool_size),
size_pool: Pool::new(size_table_pool_size),
}
}
pub fn fill(&self) {
self.node_pool.fill();
self.value_pool.fill();
self.size_pool.fill();
}
pub fn node_pool_size(&self) -> usize {
self.node_pool.get_pool_size()
}
pub fn leaf_pool_size(&self) -> usize {
self.value_pool.get_pool_size()
}
pub fn size_table_pool_size(&self) -> usize {
self.size_pool.get_pool_size()
}
}
impl<A> Default for RRBPool<A> {
fn default() -> Self {
Self::new(POOL_SIZE)
}
}
impl<A> Clone for RRBPool<A> {
fn clone(&self) -> Self {
Self {
node_pool: self.node_pool.clone(),
value_pool: self.value_pool.clone(),
size_pool: self.size_pool.clone(),
}
}
}