-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(rust): Fix input independence tests in new-streaming engine (#…
- Loading branch information
Showing
8 changed files
with
130 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
crates/polars-stream/src/nodes/input_independent_select.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use polars_core::prelude::IntoColumn; | ||
|
||
use super::compute_node_prelude::*; | ||
use crate::expression::StreamExpr; | ||
use crate::morsel::SourceToken; | ||
|
||
pub struct InputIndependentSelectNode { | ||
selectors: Vec<StreamExpr>, | ||
done: bool, | ||
} | ||
|
||
impl InputIndependentSelectNode { | ||
pub fn new(selectors: Vec<StreamExpr>) -> Self { | ||
Self { | ||
selectors, | ||
done: false, | ||
} | ||
} | ||
} | ||
|
||
impl ComputeNode for InputIndependentSelectNode { | ||
fn name(&self) -> &str { | ||
"input_independent_select" | ||
} | ||
|
||
fn update_state(&mut self, recv: &mut [PortState], send: &mut [PortState]) -> PolarsResult<()> { | ||
assert!(recv.is_empty() && send.len() == 1); | ||
send[0] = if send[0] == PortState::Done || self.done { | ||
PortState::Done | ||
} else { | ||
PortState::Ready | ||
}; | ||
Ok(()) | ||
} | ||
|
||
fn spawn<'env, 's>( | ||
&'env mut self, | ||
scope: &'s TaskScope<'s, 'env>, | ||
recv: &mut [Option<RecvPort<'_>>], | ||
send: &mut [Option<SendPort<'_>>], | ||
state: &'s ExecutionState, | ||
join_handles: &mut Vec<JoinHandle<PolarsResult<()>>>, | ||
) { | ||
assert!(recv.is_empty() && send.len() == 1); | ||
let mut sender = send[0].take().unwrap().serial(); | ||
|
||
join_handles.push(scope.spawn_task(TaskPriority::Low, async move { | ||
let empty_df = DataFrame::empty(); | ||
let mut selected = Vec::new(); | ||
for selector in self.selectors.iter() { | ||
let s = selector.evaluate(&empty_df, state).await?; | ||
selected.push(s.into_column()); | ||
} | ||
|
||
let ret = DataFrame::new_with_broadcast(selected)?; | ||
let seq = MorselSeq::default(); | ||
let source_token = SourceToken::new(); | ||
let morsel = Morsel::new(ret, seq, source_token); | ||
sender.send(morsel).await.ok(); | ||
self.done = true; | ||
Ok(()) | ||
})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters