Path: blob/main/crates/polars-arrow/src/legacy/kernels/take_agg/boolean.rs
6940 views
#![allow(unsafe_op_in_unsafe_fn)]1use super::*;23/// Take kernel for single chunk and an iterator as index.4/// # Safety5/// caller must ensure iterators indexes are in bounds6#[inline]7pub unsafe fn take_min_bool_iter_unchecked_nulls<I: IntoIterator<Item = usize>>(8arr: &BooleanArray,9indices: I,10len: IdxSize,11) -> Option<bool> {12let mut null_count = 0 as IdxSize;13let validity = arr.validity().unwrap();1415for idx in indices {16if validity.get_bit_unchecked(idx) {17if !arr.value_unchecked(idx) {18return Some(false);19}20} else {21null_count += 1;22}23}24if null_count == len { None } else { Some(true) }25}2627/// Take kernel for single chunk and an iterator as index.28/// # Safety29/// caller must ensure iterators indexes are in bounds30#[inline]31pub unsafe fn take_min_bool_iter_unchecked_no_nulls<I: IntoIterator<Item = usize>>(32arr: &BooleanArray,33indices: I,34) -> Option<bool> {35if arr.is_empty() {36return None;37}3839for idx in indices {40if !arr.value_unchecked(idx) {41return Some(false);42}43}44Some(true)45}4647/// Take kernel for single chunk and an iterator as index.48/// # Safety49/// caller must ensure iterators indexes are in bounds50#[inline]51pub unsafe fn take_max_bool_iter_unchecked_nulls<I: IntoIterator<Item = usize>>(52arr: &BooleanArray,53indices: I,54len: IdxSize,55) -> Option<bool> {56let mut null_count = 0 as IdxSize;57let validity = arr.validity().unwrap();5859for idx in indices {60if validity.get_bit_unchecked(idx) {61if arr.value_unchecked(idx) {62return Some(true);63}64} else {65null_count += 1;66}67}68if null_count == len { None } else { Some(false) }69}7071/// Take kernel for single chunk and an iterator as index.72/// # Safety73/// caller must ensure iterators indexes are in bounds74#[inline]75pub unsafe fn take_max_bool_iter_unchecked_no_nulls<I: IntoIterator<Item = usize>>(76arr: &BooleanArray,77indices: I,78) -> Option<bool> {79if arr.is_empty() {80return None;81}8283for idx in indices {84if arr.value_unchecked(idx) {85return Some(true);86}87}88Some(false)89}909192