Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-mem-engine/src/executors/projection_simple.rs
6940 views
1
use super::*;
2
3
pub struct ProjectionSimple {
4
pub(crate) input: Box<dyn Executor>,
5
pub(crate) columns: SchemaRef,
6
}
7
8
impl ProjectionSimple {
9
fn execute_impl(&mut self, df: DataFrame, columns: &[PlSmallStr]) -> PolarsResult<DataFrame> {
10
// No duplicate check as that an invariant of this node.
11
df._select_impl_unchecked(columns.as_ref())
12
}
13
}
14
15
impl Executor for ProjectionSimple {
16
fn execute(&mut self, state: &mut ExecutionState) -> PolarsResult<DataFrame> {
17
state.should_stop()?;
18
let columns = self.columns.iter_names_cloned().collect::<Vec<_>>();
19
20
let profile_name = if state.has_node_timer() {
21
let name = comma_delimited("simple-projection".to_string(), columns.as_slice());
22
Cow::Owned(name)
23
} else {
24
Cow::Borrowed("")
25
};
26
let df = self.input.execute(state)?;
27
28
if state.has_node_timer() {
29
state.record(|| self.execute_impl(df, columns.as_slice()), profile_name)
30
} else {
31
self.execute_impl(df, columns.as_slice())
32
}
33
}
34
}
35
36