Dandandan commented on code in PR #7366:
URL: https://github.com/apache/arrow-datafusion/pull/7366#discussion_r1301826330
##########
datafusion/core/src/physical_plan/joins/hash_join_utils.rs:
##########
@@ -117,37 +112,201 @@ impl JoinHashMap {
}
}
-impl SymmetricJoinHashMap {
+/// Trait defining methods that must be implemented by a hash map type to be
used for joins.
+pub trait JoinHashMapType {
+ /// The type of list used to store the hash values.
+ type NextType: IndexMut<usize, Output = u64>;
+ /// Returns a mutable reference to `self` as a `dyn Any` for dynamic
downcasting.
+ fn extend_with_value(&mut self, len: usize, value: u64);
+ /// Returns mutable references to the hash map and the next.
+ fn get_mut(&mut self) -> (&mut RawTable<(u64, u64)>, &mut Self::NextType);
+ /// Returns a reference to the hash map.
+ fn get_map(&self) -> &RawTable<(u64, u64)>;
+ /// Returns a reference to the next.
+ fn get_list(&self) -> &Self::NextType;
+}
+
+/// Implementation of `JoinHashMapType` for `JoinHashMap`.
+impl JoinHashMapType for JoinHashMap {
+ type NextType = Vec<u64>;
+
+ // Void implementation
+ fn extend_with_value(&mut self, _: usize, _: u64) {}
+
+ /// Get mutable references to the hash map and the next.
+ fn get_mut(&mut self) -> (&mut RawTable<(u64, u64)>, &mut Self::NextType) {
+ (&mut self.map, &mut self.next)
+ }
+
+ /// Get a reference to the hash map.
+ fn get_map(&self) -> &RawTable<(u64, u64)> {
+ &self.map
+ }
+
+ /// Get a reference to the next.
+ fn get_list(&self) -> &Self::NextType {
+ &self.next
+ }
+}
+
+/// Implementation of `JoinHashMapType` for `PruningJoinHashMap`.
+impl JoinHashMapType for PruningJoinHashMap {
+ type NextType = VecDeque<u64>;
+
+ // Extend with value
+ fn extend_with_value(&mut self, len: usize, value: u64) {
+ self.next.extend(repeat_n(value, len))
+ }
Review Comment:
```suggestion
fn extend_zero(&mut self, len: usize) {
self.next.extend(self.next.len() + len, 0)
}
```
Alternative suggestion (slightly more efficient).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]