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
use arrow::array::{Array, BooleanArray, ListArray, PrimitiveArray, Utf8Array};
use arrow::types::NativeType;
pub trait IsValid {
unsafe fn is_valid_unchecked(&self, i: usize) -> bool;
unsafe fn is_null_unchecked(&self, i: usize) -> bool;
}
pub trait ArrowArray: Array {}
impl ArrowArray for Utf8Array<i64> {}
impl<T: NativeType> ArrowArray for PrimitiveArray<T> {}
impl ArrowArray for BooleanArray {}
impl ArrowArray for ListArray<i64> {}
impl<A: ArrowArray> IsValid for A {
unsafe fn is_valid_unchecked(&self, i: usize) -> bool {
if let Some(b) = self.validity() {
b.get_bit_unchecked(i)
} else {
true
}
}
unsafe fn is_null_unchecked(&self, i: usize) -> bool {
!self.is_valid_unchecked(i)
}
}