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
use super::*;
pub struct BooleanChunkedBuilder {
array_builder: MutableBooleanArray,
field: Field,
}
impl ChunkedBuilder<bool, BooleanType> for BooleanChunkedBuilder {
#[inline]
fn append_value(&mut self, v: bool) {
self.array_builder.push(Some(v));
}
#[inline]
fn append_null(&mut self) {
self.array_builder.push(None);
}
fn finish(self) -> BooleanChunked {
let arr: BooleanArray = self.array_builder.into();
let arr = Arc::new(arr) as ArrayRef;
ChunkedArray {
field: Arc::new(self.field),
chunks: vec![arr],
phantom: PhantomData,
categorical_map: None,
..Default::default()
}
}
fn shrink_to_fit(&mut self) {
self.array_builder.shrink_to_fit()
}
}
impl BooleanChunkedBuilder {
pub fn new(name: &str, capacity: usize) -> Self {
BooleanChunkedBuilder {
array_builder: MutableBooleanArray::with_capacity(capacity),
field: Field::new(name, DataType::Boolean),
}
}
}