Skip to content

Commit ce1cdc8

Browse files
committed
also save hash in hashtable in primitive single group by.
1 parent 6cc4953 commit ce1cdc8

File tree

1 file changed

+8
-7
lines changed
  • datafusion/physical-plan/src/aggregates/group_values/single_group_by

1 file changed

+8
-7
lines changed

datafusion/physical-plan/src/aggregates/group_values/single_group_by/primitive.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub struct GroupValuesPrimitive<T: ArrowPrimitiveType> {
8585
///
8686
/// We don't store the hashes as hashing fixed width primitives
8787
/// is fast enough for this not to benefit performance
88-
map: HashTable<usize>,
88+
map: HashTable<(usize, u64)>,
8989
/// The group index of the null value if any
9090
null_group: Option<usize>,
9191
/// The values for each group index
@@ -127,15 +127,15 @@ where
127127
let hash = key.hash(state);
128128
let insert = self.map.entry(
129129
hash,
130-
|g| unsafe { self.values.get_unchecked(*g).is_eq(key) },
131-
|g| unsafe { self.values.get_unchecked(*g).hash(state) },
130+
|&(g, _)| unsafe { self.values.get_unchecked(g).is_eq(key) },
131+
|&(_, h)| h,
132132
);
133133

134134
match insert {
135-
hashbrown::hash_table::Entry::Occupied(o) => *o.get(),
135+
hashbrown::hash_table::Entry::Occupied(o) => o.get().0,
136136
hashbrown::hash_table::Entry::Vacant(v) => {
137137
let g = self.values.len();
138-
v.insert(g);
138+
v.insert((g, hash));
139139
self.values.push(key);
140140
g
141141
}
@@ -181,12 +181,13 @@ where
181181
build_primitive(std::mem::take(&mut self.values), self.null_group.take())
182182
}
183183
EmitTo::First(n) => {
184-
self.map.retain(|group_idx| {
184+
self.map.retain(|entry| {
185185
// Decrement group index by n
186+
let group_idx = entry.0;
186187
match group_idx.checked_sub(n) {
187188
// Group index was >= n, shift value down
188189
Some(sub) => {
189-
*group_idx = sub;
190+
entry.0 = sub;
190191
true
191192
}
192193
// Group index was < n, so remove from table

0 commit comments

Comments
 (0)