Path: blob/main/crates/polars-compute/src/comparisons/scalar.rs
6939 views
use arrow::array::PrimitiveArray;1use arrow::bitmap::Bitmap;2use polars_utils::total_ord::TotalOrd;34use super::{TotalEqKernel, TotalOrdKernel};5use crate::NotSimdPrimitive;67impl<T: NotSimdPrimitive + TotalOrd> TotalEqKernel for PrimitiveArray<T> {8type Scalar = T;910fn tot_eq_kernel(&self, other: &Self) -> Bitmap {11assert!(self.len() == other.len());12self.values()13.iter()14.zip(other.values().iter())15.map(|(l, r)| l.tot_eq(r))16.collect()17}1819fn tot_ne_kernel(&self, other: &Self) -> Bitmap {20assert!(self.len() == other.len());21self.values()22.iter()23.zip(other.values().iter())24.map(|(l, r)| l.tot_ne(r))25.collect()26}2728fn tot_eq_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap {29self.values().iter().map(|l| l.tot_eq(other)).collect()30}3132fn tot_ne_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap {33self.values().iter().map(|l| l.tot_ne(other)).collect()34}35}3637impl<T: NotSimdPrimitive + TotalOrd> TotalOrdKernel for PrimitiveArray<T> {38type Scalar = T;3940fn tot_lt_kernel(&self, other: &Self) -> Bitmap {41assert!(self.len() == other.len());42self.values()43.iter()44.zip(other.values().iter())45.map(|(l, r)| l.tot_lt(r))46.collect()47}4849fn tot_le_kernel(&self, other: &Self) -> Bitmap {50assert!(self.len() == other.len());51self.values()52.iter()53.zip(other.values().iter())54.map(|(l, r)| l.tot_le(r))55.collect()56}5758fn tot_lt_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap {59self.values().iter().map(|l| l.tot_lt(other)).collect()60}6162fn tot_le_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap {63self.values().iter().map(|l| l.tot_le(other)).collect()64}6566fn tot_gt_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap {67self.values().iter().map(|l| l.tot_gt(other)).collect()68}6970fn tot_ge_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap {71self.values().iter().map(|l| l.tot_ge(other)).collect()72}73}747576