Skip to content

Commit 9b19d36

Browse files
authored
Minor: Use resize instead of extend for adding static values in SortMergeJoin logic (#13861)
Thanks @Dandandan
1 parent 75202b5 commit 9b19d36

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

datafusion/physical-plan/src/joins/sort_merge_join.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ impl SortMergeJoinStream {
15781578
.append_nulls(num_rows);
15791579
self.output_record_batches
15801580
.batch_ids
1581-
.extend(vec![0; num_rows]);
1581+
.resize(self.output_record_batches.batch_ids.len() + num_rows, 0);
15821582

15831583
self.output_record_batches.batches.push(record_batch);
15841584
}
@@ -1622,7 +1622,7 @@ impl SortMergeJoinStream {
16221622
.append_nulls(num_rows);
16231623
self.output_record_batches
16241624
.batch_ids
1625-
.extend(vec![0; num_rows]);
1625+
.resize(self.output_record_batches.batch_ids.len() + num_rows, 0);
16261626
self.output_record_batches.batches.push(record_batch);
16271627
}
16281628
buffered_batch.join_filter_not_matched_map.clear();
@@ -1757,10 +1757,10 @@ impl SortMergeJoinStream {
17571757
self.output_record_batches.filter_mask.extend(pre_mask);
17581758
}
17591759
self.output_record_batches.row_indices.extend(&left_indices);
1760-
self.output_record_batches.batch_ids.extend(vec![
1761-
self.streamed_batch_counter.load(Relaxed);
1762-
left_indices.len()
1763-
]);
1760+
self.output_record_batches.batch_ids.resize(
1761+
self.output_record_batches.batch_ids.len() + left_indices.len(),
1762+
self.streamed_batch_counter.load(Relaxed),
1763+
);
17641764

17651765
// For outer joins, we need to push the null joined rows to the output if
17661766
// all joined rows are failed on the join filter.

0 commit comments

Comments
 (0)