Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BatchPartitioner (#2285) #2287

Merged
merged 3 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ballista/rust/core/src/execution_plans/shuffle_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl ShuffleWriterExec {
let mut partitioner = BatchPartitioner::new(
Partitioning::Hash(exprs.clone(), *n),
write_metrics.repart_time.clone(),
);
)?;

while let Some(result) = stream.next().await {
let input_batch = result?;
Expand Down
13 changes: 9 additions & 4 deletions datafusion/core/src/physical_plan/repartition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl BatchPartitioner {
/// Create a new [`BatchPartitioner`] with the provided [`Partitioning`]
///
/// The time spent repartitioning will be recorded to `timer`
pub fn new(partitioning: Partitioning, timer: metrics::Time) -> Self {
pub fn new(partitioning: Partitioning, timer: metrics::Time) -> Result<Self> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn´t this be try_new now by convention?

let state = match partitioning {
Partitioning::RoundRobinBatch(num_partitions) => {
BatchPartitionerState::RoundRobin {
Expand All @@ -102,10 +102,15 @@ impl BatchPartitioner {
random_state: ahash::RandomState::with_seeds(0, 0, 0, 0),
hash_buffer: vec![],
},
Partitioning::UnknownPartitioning(_) => unreachable!(),
other => {
return Err(DataFusionError::NotImplemented(format!(
"Unsupported repartitioning scheme {:?}",
other
)))
}
};

Self { state, timer }
Ok(Self { state, timer })
}

/// Partition the provided [`RecordBatch`] into one or more partitioned [`RecordBatch`]
Expand Down Expand Up @@ -428,7 +433,7 @@ impl RepartitionExec {
context: Arc<TaskContext>,
) -> Result<()> {
let mut partitioner =
BatchPartitioner::new(partitioning, r_metrics.repart_time.clone());
BatchPartitioner::new(partitioning, r_metrics.repart_time.clone())?;

// execute the child operator
let timer = r_metrics.fetch_time.timer();
Expand Down