polars_arrow/legacy/
is_valid.rs

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