Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/src/dsl/bitwise.rs
6939 views
1
use super::{BitwiseFunction, Expr, FunctionExpr};
2
3
impl Expr {
4
/// Evaluate the number of set bits.
5
pub fn bitwise_count_ones(self) -> Self {
6
self.map_unary(FunctionExpr::Bitwise(BitwiseFunction::CountOnes))
7
}
8
9
/// Evaluate the number of unset bits.
10
pub fn bitwise_count_zeros(self) -> Self {
11
self.map_unary(FunctionExpr::Bitwise(BitwiseFunction::CountZeros))
12
}
13
14
/// Evaluate the number most-significant set bits before seeing an unset bit.
15
pub fn bitwise_leading_ones(self) -> Self {
16
self.map_unary(FunctionExpr::Bitwise(BitwiseFunction::LeadingOnes))
17
}
18
19
/// Evaluate the number most-significant unset bits before seeing an set bit.
20
pub fn bitwise_leading_zeros(self) -> Self {
21
self.map_unary(FunctionExpr::Bitwise(BitwiseFunction::LeadingZeros))
22
}
23
24
/// Evaluate the number least-significant set bits before seeing an unset bit.
25
pub fn bitwise_trailing_ones(self) -> Self {
26
self.map_unary(FunctionExpr::Bitwise(BitwiseFunction::TrailingOnes))
27
}
28
29
/// Evaluate the number least-significant unset bits before seeing an set bit.
30
pub fn bitwise_trailing_zeros(self) -> Self {
31
self.map_unary(FunctionExpr::Bitwise(BitwiseFunction::TrailingZeros))
32
}
33
34
/// Perform an aggregation of bitwise ANDs
35
pub fn bitwise_and(self) -> Self {
36
self.map_unary(FunctionExpr::Bitwise(BitwiseFunction::And))
37
}
38
39
/// Perform an aggregation of bitwise ORs
40
pub fn bitwise_or(self) -> Self {
41
self.map_unary(FunctionExpr::Bitwise(BitwiseFunction::Or))
42
}
43
44
/// Perform an aggregation of bitwise XORs
45
pub fn bitwise_xor(self) -> Self {
46
self.map_unary(FunctionExpr::Bitwise(BitwiseFunction::Xor))
47
}
48
}
49
50