polars_plan/frame/
opt_state.rs1use bitflags::bitflags;
2
3bitflags! {
4#[derive(Copy, Clone, Debug)]
5 pub struct OptFlags: u32 {
7 const PROJECTION_PUSHDOWN = 1;
9 const PREDICATE_PUSHDOWN = 1 << 2;
11 const CLUSTER_WITH_COLUMNS = 1 << 3;
13 const TYPE_COERCION = 1 << 4;
15 const SIMPLIFY_EXPR = 1 << 5;
17 const TYPE_CHECK = 1 << 6;
19 const SLICE_PUSHDOWN = 1 << 7;
21 const COMM_SUBPLAN_ELIM = 1 << 8;
24 const COMM_SUBEXPR_ELIM = 1 << 9;
27 const STREAMING = 1 << 10;
29 const NEW_STREAMING = 1 << 11;
30 const EAGER = 1 << 12;
32 const ROW_ESTIMATE = 1 << 13;
34 const FAST_PROJECTION = 1 << 14;
36 const COLLAPSE_JOINS = 1 << 15;
38 const CHECK_ORDER_OBSERVE = 1 << 16;
41 }
42}
43
44impl OptFlags {
45 pub fn schema_only() -> Self {
46 Self::TYPE_COERCION | Self::TYPE_CHECK
47 }
48
49 pub fn eager(&self) -> bool {
50 self.contains(OptFlags::EAGER)
51 }
52
53 pub fn cluster_with_columns(&self) -> bool {
54 self.contains(OptFlags::CLUSTER_WITH_COLUMNS)
55 }
56
57 pub fn collapse_joins(&self) -> bool {
58 self.contains(OptFlags::COLLAPSE_JOINS)
59 }
60
61 pub fn predicate_pushdown(&self) -> bool {
62 self.contains(OptFlags::PREDICATE_PUSHDOWN)
63 }
64
65 pub fn projection_pushdown(&self) -> bool {
66 self.contains(OptFlags::PROJECTION_PUSHDOWN)
67 }
68 pub fn simplify_expr(&self) -> bool {
69 self.contains(OptFlags::SIMPLIFY_EXPR)
70 }
71 pub fn slice_pushdown(&self) -> bool {
72 self.contains(OptFlags::SLICE_PUSHDOWN)
73 }
74 pub fn streaming(&self) -> bool {
75 self.contains(OptFlags::STREAMING)
76 }
77 pub fn new_streaming(&self) -> bool {
78 self.contains(OptFlags::NEW_STREAMING)
79 }
80 pub fn fast_projection(&self) -> bool {
81 self.contains(OptFlags::FAST_PROJECTION)
82 }
83}
84
85impl Default for OptFlags {
86 fn default() -> Self {
87 Self::from_bits_truncate(u32::MAX) & !Self::NEW_STREAMING & !Self::STREAMING & !Self::EAGER
88 }
89}
90
91pub type AllowedOptimizations = OptFlags;