Skip to content

Commit

Permalink
Replace BooleanArray::extend with append_n
Browse files Browse the repository at this point in the history
  • Loading branch information
comphead committed Dec 18, 2024
1 parent 1fc7769 commit 5f9769a
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions datafusion/physical-plan/src/joins/sort_merge_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,7 @@ fn get_corrected_filter_mask(
}

// Generate null joined rows for records which have no matching join key
let null_matched = expected_size - corrected_mask.len();
corrected_mask.extend(vec![Some(false); null_matched]);
corrected_mask.append_n(expected_size - corrected_mask.len(), false);
Some(corrected_mask.finish())
}
JoinType::LeftMark => {
Expand All @@ -879,8 +878,7 @@ fn get_corrected_filter_mask(
}

// Generate null joined rows for records which have no matching join key
let null_matched = expected_size - corrected_mask.len();
corrected_mask.extend(vec![Some(false); null_matched]);
corrected_mask.append_n(expected_size - corrected_mask.len(), false);
Some(corrected_mask.finish())
}
JoinType::LeftSemi => {
Expand Down Expand Up @@ -922,9 +920,9 @@ fn get_corrected_filter_mask(
corrected_mask.append_null();
}
}

let null_matched = expected_size - corrected_mask.len();
corrected_mask.extend(vec![Some(true); null_matched]);
// Generate null joined rows for records which have no matching join key,
// for LeftAnti non-matched considered as true
corrected_mask.append_n(expected_size - corrected_mask.len(), true);
Some(corrected_mask.finish())
}
JoinType::Full => {
Expand Down Expand Up @@ -1569,10 +1567,10 @@ impl SortMergeJoinStream {
let num_rows = record_batch.num_rows();
self.output_record_batches
.filter_mask
.extend(&BooleanArray::from(vec![None; num_rows]));
.append_nulls(num_rows);
self.output_record_batches
.row_indices
.extend(&UInt64Array::from(vec![None; num_rows]));
.append_nulls(num_rows);
self.output_record_batches
.batch_ids
.extend(vec![0; num_rows]);
Expand Down Expand Up @@ -1613,10 +1611,10 @@ impl SortMergeJoinStream {

self.output_record_batches
.filter_mask
.extend(&BooleanArray::from(vec![None; num_rows]));
.append_nulls(num_rows);
self.output_record_batches
.row_indices
.extend(&UInt64Array::from(vec![None; num_rows]));
.append_nulls(num_rows);
self.output_record_batches
.batch_ids
.extend(vec![0; num_rows]);
Expand Down

0 comments on commit 5f9769a

Please sign in to comment.