polars_plan/dsl/
bitwise.rs1use super::{BitwiseFunction, Expr, FunctionExpr, FunctionFlags};
2
3impl Expr {
4 pub fn bitwise_count_ones(self) -> Self {
6 self.apply_private(FunctionExpr::Bitwise(BitwiseFunction::CountOnes))
7 }
8
9 pub fn bitwise_count_zeros(self) -> Self {
11 self.apply_private(FunctionExpr::Bitwise(BitwiseFunction::CountZeros))
12 }
13
14 pub fn bitwise_leading_ones(self) -> Self {
16 self.apply_private(FunctionExpr::Bitwise(BitwiseFunction::LeadingOnes))
17 }
18
19 pub fn bitwise_leading_zeros(self) -> Self {
21 self.apply_private(FunctionExpr::Bitwise(BitwiseFunction::LeadingZeros))
22 }
23
24 pub fn bitwise_trailing_ones(self) -> Self {
26 self.apply_private(FunctionExpr::Bitwise(BitwiseFunction::TrailingOnes))
27 }
28
29 pub fn bitwise_trailing_zeros(self) -> Self {
31 self.apply_private(FunctionExpr::Bitwise(BitwiseFunction::TrailingZeros))
32 }
33
34 pub fn bitwise_and(self) -> Self {
36 self.apply_private(FunctionExpr::Bitwise(BitwiseFunction::And))
37 .with_function_options(|mut options| {
38 options.flags |= FunctionFlags::RETURNS_SCALAR;
39 options
40 })
41 }
42
43 pub fn bitwise_or(self) -> Self {
45 self.apply_private(FunctionExpr::Bitwise(BitwiseFunction::Or))
46 .with_function_options(|mut options| {
47 options.flags |= FunctionFlags::RETURNS_SCALAR;
48 options
49 })
50 }
51
52 pub fn bitwise_xor(self) -> Self {
54 self.apply_private(FunctionExpr::Bitwise(BitwiseFunction::Xor))
55 .with_function_options(|mut options| {
56 options.flags |= FunctionFlags::RETURNS_SCALAR;
57 options
58 })
59 }
60}