polars_compute/comparisons/
mod.rs1use arrow::array::Array;
2use arrow::bitmap::{self, Bitmap};
3
4pub trait TotalEqKernel: Sized + Array {
5 type Scalar: ?Sized;
6
7 fn tot_eq_kernel(&self, other: &Self) -> Bitmap;
10 fn tot_ne_kernel(&self, other: &Self) -> Bitmap;
11 fn tot_eq_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap;
12 fn tot_ne_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap;
13
14 fn tot_eq_missing_kernel(&self, other: &Self) -> Bitmap {
17 let q = self.tot_eq_kernel(other);
18 let combined = match (self.validity(), other.validity()) {
19 (None, None) => q,
20 (None, Some(r)) => &q & r,
21 (Some(l), None) => &q & l,
22 (Some(l), Some(r)) => bitmap::ternary(&q, l, r, |q, l, r| (q & l & r) | !(l | r)),
23 };
24 combined
25 }
26
27 fn tot_ne_missing_kernel(&self, other: &Self) -> Bitmap {
28 let q = self.tot_ne_kernel(other);
29 let combined = match (self.validity(), other.validity()) {
30 (None, None) => q,
31 (None, Some(r)) => &q | &!r,
32 (Some(l), None) => &q | &!l,
33 (Some(l), Some(r)) => bitmap::ternary(&q, l, r, |q, l, r| (q & l & r) | (l ^ r)),
34 };
35 combined
36 }
37 fn tot_eq_missing_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap {
38 let q = self.tot_eq_kernel_broadcast(other);
39 if let Some(valid) = self.validity() {
40 bitmap::binary(&q, valid, |q, v| q & v)
41 } else {
42 q
43 }
44 }
45
46 fn tot_ne_missing_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap {
47 let q = self.tot_ne_kernel_broadcast(other);
48 if let Some(valid) = self.validity() {
49 bitmap::binary(&q, valid, |q, v| q | !v)
50 } else {
51 q
52 }
53 }
54}
55
56pub trait TotalOrdKernel: Sized + Array {
58 type Scalar: ?Sized;
59
60 fn tot_lt_kernel(&self, other: &Self) -> Bitmap;
63 fn tot_le_kernel(&self, other: &Self) -> Bitmap;
64 fn tot_gt_kernel(&self, other: &Self) -> Bitmap {
65 other.tot_lt_kernel(self)
66 }
67 fn tot_ge_kernel(&self, other: &Self) -> Bitmap {
68 other.tot_le_kernel(self)
69 }
70
71 fn tot_lt_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap;
74 fn tot_le_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap;
75 fn tot_gt_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap;
76 fn tot_ge_kernel_broadcast(&self, other: &Self::Scalar) -> Bitmap;
77}
78
79mod binary;
80mod boolean;
81mod dictionary;
82mod dyn_array;
83mod list;
84mod null;
85mod scalar;
86mod struct_;
87mod utf8;
88mod view;
89
90#[cfg(feature = "simd")]
91mod _simd_dtypes {
92 use arrow::types::{days_ms, f16, i256, months_days_ns};
93
94 use crate::NotSimdPrimitive;
95
96 impl NotSimdPrimitive for f16 {}
97 impl NotSimdPrimitive for i256 {}
98 impl NotSimdPrimitive for days_ms {}
99 impl NotSimdPrimitive for months_days_ns {}
100}
101
102#[cfg(feature = "simd")]
103mod simd;
104
105#[cfg(feature = "dtype-array")]
106mod array;