From a93386f168f7feac6fd2c396c6b363a4c545e827 Mon Sep 17 00:00:00 2001 From: comphead Date: Fri, 20 Dec 2024 09:21:05 -0800 Subject: [PATCH] Minor: Use `resize` instead of `extend` for adding static values in SortMergeJoin logic --- .../physical-plan/src/joins/sort_merge_join.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/datafusion/physical-plan/src/joins/sort_merge_join.rs b/datafusion/physical-plan/src/joins/sort_merge_join.rs index f17b99d81d7b..b8cb7b313bc1 100644 --- a/datafusion/physical-plan/src/joins/sort_merge_join.rs +++ b/datafusion/physical-plan/src/joins/sort_merge_join.rs @@ -1578,7 +1578,7 @@ impl SortMergeJoinStream { .append_nulls(num_rows); self.output_record_batches .batch_ids - .extend(vec![0; num_rows]); + .resize(self.output_record_batches.batch_ids.len() + num_rows, 0); self.output_record_batches.batches.push(record_batch); } @@ -1622,7 +1622,7 @@ impl SortMergeJoinStream { .append_nulls(num_rows); self.output_record_batches .batch_ids - .extend(vec![0; num_rows]); + .resize(self.output_record_batches.batch_ids.len() + num_rows, 0); self.output_record_batches.batches.push(record_batch); } buffered_batch.join_filter_not_matched_map.clear(); @@ -1757,10 +1757,10 @@ impl SortMergeJoinStream { self.output_record_batches.filter_mask.extend(pre_mask); } self.output_record_batches.row_indices.extend(&left_indices); - self.output_record_batches.batch_ids.extend(vec![ - self.streamed_batch_counter.load(Relaxed); - left_indices.len() - ]); + self.output_record_batches.batch_ids.resize( + self.output_record_batches.batch_ids.len() + left_indices.len(), + self.streamed_batch_counter.load(Relaxed), + ); // For outer joins, we need to push the null joined rows to the output if // all joined rows are failed on the join filter.