polars_arrow/legacy/
is_valid.rs

1use crate::array::{
2    Array, BinaryArray, BooleanArray, FixedSizeListArray, ListArray, PrimitiveArray, Utf8Array,
3};
4use crate::types::NativeType;
5
6pub trait IsValid {
7    /// # Safety
8    /// no bound checks
9    unsafe fn is_valid_unchecked(&self, i: usize) -> bool;
10}
11
12pub trait ArrowArray: Array {}
13
14impl ArrowArray for BinaryArray<i64> {}
15impl ArrowArray for Utf8Array<i64> {}
16impl<T: NativeType> ArrowArray for PrimitiveArray<T> {}
17impl ArrowArray for BooleanArray {}
18impl ArrowArray for ListArray<i64> {}
19impl ArrowArray for FixedSizeListArray {}
20
21impl<A: ArrowArray> IsValid for A {
22    #[inline]
23    unsafe fn is_valid_unchecked(&self, i: usize) -> bool {
24        !self.is_null_unchecked(i)
25    }
26}