Dandandan commented on code in PR #15768: URL: https://github.com/apache/datafusion/pull/15768#discussion_r2051763714
########## datafusion/physical-plan/src/repartition/mod.rs: ########## @@ -298,25 +299,15 @@ impl BatchPartitioner { .into_iter() .enumerate() .filter_map(|(partition, indices)| { - let indices: PrimitiveArray<UInt32Type> = indices.into(); (!indices.is_empty()).then_some((partition, indices)) }) .map(move |(partition, indices)| { // Tracking time required for repartitioned batches construction let _timer = partitioner_timer.timer(); + let b: Vec<&RecordBatch> = batches.iter().collect(); // Produce batches based on indices - let columns = take_arrays(batch.columns(), &indices, None)?; - - let mut options = RecordBatchOptions::new(); - options = options.with_row_count(Some(indices.len())); - let batch = RecordBatch::try_new_with_options( - batch.schema(), - columns, - &options, - ) - .unwrap(); - + let batch = interleave_record_batch(&b, &indices)?; Review Comment: Yeah the speedup comes from avoiding copying the data a second time in `concat` / CoalesceBatches. So when using `take_in` we should be careful to use it once (for a single destination batch) to avoid doing the concat on the small batches -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org