Path: blob/main/crates/polars-compute/src/comparisons/boolean.rs
6939 views
use arrow::array::BooleanArray;1use arrow::bitmap::{self, Bitmap};23use super::{TotalEqKernel, TotalOrdKernel};45impl TotalEqKernel for BooleanArray {6type Scalar = bool;78fn tot_eq_kernel(&self, other: &Self) -> Bitmap {9bitmap::binary(self.values(), other.values(), |l, r| !(l ^ r))10}1112fn tot_ne_kernel(&self, other: &Self) -> Bitmap {13self.values() ^ other.values()14}1516fn tot_eq_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap {17if *other {18self.values().clone()19} else {20!self.values()21}22}2324fn tot_ne_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap {25self.tot_eq_kernel_broadcast(&!*other)26}27}2829impl TotalOrdKernel for BooleanArray {30type Scalar = bool;3132fn tot_lt_kernel(&self, other: &Self) -> Bitmap {33bitmap::binary(self.values(), other.values(), |l, r| !l & r)34}3536fn tot_le_kernel(&self, other: &Self) -> Bitmap {37bitmap::binary(self.values(), other.values(), |l, r| !l | r)38}3940fn tot_lt_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap {41if *other {42!self.values()43} else {44Bitmap::new_zeroed(self.len())45}46}4748fn tot_le_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap {49if *other {50Bitmap::new_with_value(true, self.len())51} else {52!self.values()53}54}5556fn tot_gt_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap {57if *other {58Bitmap::new_zeroed(self.len())59} else {60self.values().clone()61}62}6364fn tot_ge_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap {65if *other {66self.values().clone()67} else {68Bitmap::new_with_value(true, self.len())69}70}71}727374