Skip to content

Commit 89677ae

Browse files
RachelintShiKaiWi
andauthored
Check hashes first during probing the aggr hash table (apache#11718)
* check hashes first during probing. * fix style. --------- Co-authored-by: xikai.wxk <[email protected]>
1 parent abeb8b4 commit 89677ae

File tree

1 file changed

+5
-4
lines changed
  • datafusion/physical-plan/src/aggregates/group_values

1 file changed

+5
-4
lines changed

datafusion/physical-plan/src/aggregates/group_values/row.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@ impl GroupValues for GroupValuesRows {
120120
batch_hashes.resize(n_rows, 0);
121121
create_hashes(cols, &self.random_state, batch_hashes)?;
122122

123-
for (row, &hash) in batch_hashes.iter().enumerate() {
124-
let entry = self.map.get_mut(hash, |(_hash, group_idx)| {
123+
for (row, &target_hash) in batch_hashes.iter().enumerate() {
124+
let entry = self.map.get_mut(target_hash, |(exist_hash, group_idx)| {
125125
// verify that a group that we are inserting with hash is
126126
// actually the same key value as the group in
127127
// existing_idx (aka group_values @ row)
128-
group_rows.row(row) == group_values.row(*group_idx)
128+
target_hash == *exist_hash
129+
&& group_rows.row(row) == group_values.row(*group_idx)
129130
});
130131

131132
let group_idx = match entry {
@@ -139,7 +140,7 @@ impl GroupValues for GroupValuesRows {
139140

140141
// for hasher function, use precomputed hash value
141142
self.map.insert_accounted(
142-
(hash, group_idx),
143+
(target_hash, group_idx),
143144
|(hash, _group_index)| *hash,
144145
&mut self.map_size,
145146
);

0 commit comments

Comments
 (0)