Skip to content

Commit

Permalink
dont assign each element
Browse files Browse the repository at this point in the history
  • Loading branch information
korowa committed Nov 12, 2023
1 parent 74d8d69 commit 7993f33
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions datafusion/physical-plan/src/joins/hash_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,22 +726,26 @@ where
hash_map.extend_zero(batch.num_rows());
chain_tails.resize(chain_tails.len() + batch.num_rows(), 0);


// insert hashes to key of the hashmap
let (mut_map, mut_list) = hash_map.get_mut();

for (row, hash_value) in hash_values.iter().enumerate() {
let item = mut_map.get_mut(*hash_value, |(hash, _)| *hash_value == *hash);
if let Some((_, index)) = item {
// Map stores head index of chain
// Get saved tail for current chain
let head = *index as usize;
// Get tail for current chain
let tail = chain_tails[head];
let tail_idx = chain_tails.get_mut(head).unwrap();
let tail = if *tail_idx == 0 {
head
} else {
*tail_idx
};

// Set next value for current tail
mut_list[tail - 1] = (row + offset + 1) as u64;
// Sett current row as new tail
chain_tails[head] = row + offset + 1;
// Update tail
*tail_idx = row + offset + 1;
} else {
chain_tails[row + offset + 1] = row + offset + 1;
mut_map.insert(
*hash_value,
// store the value + 1 as 0 value reserved for end of list
Expand Down

0 comments on commit 7993f33

Please sign in to comment.