Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-stream/src/nodes/io_sinks2/components/par_utils.rs
7884 views
1
use polars_core::prelude::Column;
2
3
use crate::async_executor::TaskPriority;
4
use crate::async_primitives::opt_spawned_future::parallelize_first_to_local;
5
6
/// Parallel rechunk of each column over the computational async executor.
7
pub async fn rechunk_par(columns: &mut [Column]) {
8
for fut in parallelize_first_to_local(
9
TaskPriority::Low,
10
columns.iter_mut().enumerate().filter_map(|(i, c)| {
11
(c.n_chunks() > 1).then(|| {
12
let c = std::mem::take(c);
13
async move { (i, c.rechunk()) }
14
})
15
}),
16
) {
17
let (i, c) = fut.await;
18
columns[i] = c;
19
}
20
}
21
22