gene-bordegaray commented on code in PR #23231:
URL: https://github.com/apache/datafusion/pull/23231#discussion_r3539042020


##########
datafusion/physical-plan/src/repartition/mod.rs:
##########
@@ -831,22 +869,95 @@ impl BatchPartitioner {
 
                     Box::new(partitioned_batches.into_iter())
                 }
+                BatchPartitionerState::Range {
+                    ordering,
+                    sort_options,
+                    split_points,
+                    indices,
+                    partition_buffer,
+                } => {
+                    // Tracking time required for distributing indexes across 
output partitions
+                    let timer = self.timer.timer();
+                    if split_points.is_empty() {
+                        timer.done();
+                        Box::new(std::iter::once(Ok((0, batch))))
+                    } else {
+                        let arrays = evaluate_expressions_to_arrays(
+                            ordering.iter().map(|e| &e.expr),
+                            &batch,
+                        )?;
+
+                        indices.iter_mut().for_each(|v| v.clear());
+
+                        Self::partition_range_indices(
+                            &arrays,
+                            split_points,
+                            sort_options,
+                            partition_buffer,
+                            indices,
+                        )?;
+
+                        // Finished building index-arrays for output partitions
+                        timer.done();
+
+                        let partitioned_batches =
+                            Self::partition_grouped_take(&batch, indices, 
&self.timer)?;
+
+                        Box::new(partitioned_batches.into_iter())
+                    }
+                }
             };
 
         Ok(it)
     }
 
+    /// Groups input row indices by range partition. This populates 
`indices[p]` with the
+    /// row indices from `arrays` that belong in output partition `p` 
according to `split_points` and `sort_options`.

Review Comment:
   wow I have never heard of that very cool



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to