Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-expr/src/lib.rs
8396 views
1
#![cfg_attr(
2
feature = "allow_unused",
3
allow(unused, dead_code, irrefutable_let_patterns)
4
)] // Maybe be caused by some feature
5
pub mod dispatch;
6
mod expressions;
7
pub mod groups;
8
pub mod hash_keys;
9
pub mod hot_groups;
10
pub mod idx_table;
11
pub mod planner;
12
pub mod prelude;
13
pub mod reduce;
14
pub mod state;
15
16
use polars_utils::IdxSize;
17
18
pub use crate::planner::{ExpressionConversionState, create_physical_expr};
19
20
/// An index where the top bit indicates whether a value should be evicted.
21
#[derive(Copy, Clone, Debug)]
22
#[repr(transparent)]
23
pub struct EvictIdx(IdxSize);
24
25
impl EvictIdx {
26
#[inline(always)]
27
pub fn new(idx: IdxSize, should_evict: bool) -> Self {
28
debug_assert!(idx >> (IdxSize::BITS - 1) == 0);
29
Self(idx | ((should_evict as IdxSize) << (IdxSize::BITS - 1)))
30
}
31
32
#[inline(always)]
33
pub fn idx(&self) -> usize {
34
(self.0 & (IdxSize::MAX >> 1)) as usize
35
}
36
37
#[inline(always)]
38
pub fn should_evict(&self) -> bool {
39
(self.0 >> (IdxSize::BITS - 1)) != 0
40
}
41
42
pub fn cast_slice(idxs: &[IdxSize]) -> &[EvictIdx] {
43
// SAFETY: same size and align, repr(transparent).
44
unsafe { std::slice::from_raw_parts(idxs.as_ptr() as *const EvictIdx, idxs.len()) }
45
}
46
}
47
48