viirya commented on code in PR #11218:
URL: https://github.com/apache/datafusion/pull/11218#discussion_r1682245542
##########
datafusion/physical-plan/src/joins/sort_merge_join.rs:
##########
@@ -1502,13 +1572,45 @@ fn get_buffered_columns(
buffered_data: &BufferedData,
buffered_batch_idx: usize,
buffered_indices: &UInt64Array,
-) -> Result<Vec<ArrayRef>, ArrowError> {
- buffered_data.batches[buffered_batch_idx]
- .batch
- .columns()
- .iter()
- .map(|column| take(column, &buffered_indices, None))
- .collect::<Result<Vec<_>, ArrowError>>()
+) -> Result<Vec<ArrayRef>> {
+ get_buffered_columns_from_batch(
+ &buffered_data.batches[buffered_batch_idx],
+ buffered_indices,
+ )
+}
+
+#[inline(always)]
+fn get_buffered_columns_from_batch(
+ buffered_batch: &BufferedBatch,
+ buffered_indices: &UInt64Array,
+) -> Result<Vec<ArrayRef>> {
+ match (&buffered_batch.spill_file, &buffered_batch.batch) {
+ // In memory batch
+ (None, Some(batch)) => Ok(batch
+ .columns()
+ .iter()
+ .map(|column| take(column, &buffered_indices, None))
+ .collect::<Result<Vec<_>, ArrowError>>()
+ .map_err(Into::<DataFusionError>::into)?),
+ // If the batch was spilled to disk, less likely
+ (Some(spill_file), None) => {
+ let mut buffered_cols: Vec<ArrayRef> =
+ Vec::with_capacity(buffered_indices.len());
Review Comment:
`buffered_indices.len()` is the length of arrays. I think the capacity
should be the number of columns of the batch.
--
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]