Dandandan commented on code in PR #20463:
URL: https://github.com/apache/datafusion/pull/20463#discussion_r2836380395


##########
datafusion/physical-plan/src/joins/sort_merge_join/stream.rs:
##########
@@ -1248,13 +1490,24 @@ impl SortMergeJoinStream {
                 continue;
             }
 
-            let mut left_columns = self
-                .streamed_batch
-                .batch
-                .columns()
-                .iter()
-                .map(|column| take(column, &left_indices, None))
-                .collect::<Result<Vec<_>, ArrowError>>()?;
+            let mut left_columns = if let Some(range) = 
is_contiguous_range(&left_indices)
+            {
+                // When indices form a contiguous range (common for the 
streamed
+                // side which advances sequentially), use zero-copy slice 
instead
+                // of the O(n) take kernel.
+                self.streamed_batch
+                    .batch
+                    .slice(range.start, range.len())
+                    .columns()
+                    .to_vec()
+            } else {
+                self.streamed_batch

Review Comment:
   Or https://arrow.apache.org/rust/arrow/compute/fn.take_arrays.html



-- 
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