Dandandan commented on code in PR #20463:
URL: https://github.com/apache/datafusion/pull/20463#discussion_r2836379101
##########
datafusion/physical-plan/src/joins/sort_merge_join/stream.rs:
##########
@@ -1597,12 +2027,21 @@ fn fetch_right_columns_from_batch_by_idxs(
) -> Result<Vec<ArrayRef>> {
match &buffered_batch.batch {
// In memory batch
- BufferedBatchState::InMemory(batch) => Ok(batch
- .columns()
- .iter()
- .map(|column| take(column, &buffered_indices, None))
- .collect::<Result<Vec<_>, ArrowError>>()
- .map_err(Into::<DataFusionError>::into)?),
+ // In memory batch
+ BufferedBatchState::InMemory(batch) => {
+ // When indices form a contiguous range (common in SMJ since the
+ // buffered side is scanned sequentially), use zero-copy slice.
+ if let Some(range) = is_contiguous_range(buffered_indices) {
+ Ok(batch.slice(range.start, range.len()).columns().to_vec())
+ } else {
+ Ok(batch
+ .columns()
+ .iter()
+ .map(|column| take(column, buffered_indices, None))
Review Comment:
Minor: this could use
https://arrow.apache.org/rust/arrow/compute/fn.take_record_batch.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]