Dandandan commented on a change in pull request #9116:
URL: https://github.com/apache/arrow/pull/9116#discussion_r554613355



##########
File path: rust/datafusion/src/physical_plan/hash_join.rs
##########
@@ -575,6 +542,199 @@ fn build_join_indexes(
         }
     }
 }
+use core::hash::BuildHasher;
+
+/// `Hasher` that returns the same `u64` value as a hash, to avoid re-hashing
+/// it when inserting/indexing or regrowing the `HashMap`
+struct IdHasher {
+    hash: u64,
+}
+
+impl Hasher for IdHasher {
+    fn finish(&self) -> u64 {
+        self.hash
+    }
+
+    fn write_u64(&mut self, i: u64) {
+        self.hash = i;
+    }
+
+    fn write(&mut self, _bytes: &[u8]) {
+        unreachable!("IdHasher should only be used for u64 keys")
+    }
+}
+
+#[derive(Debug)]
+struct IdHashBuilder {}
+
+impl BuildHasher for IdHashBuilder {
+    type Hasher = IdHasher;
+
+    fn build_hasher(&self) -> Self::Hasher {
+        IdHasher { hash: 0 }
+    }
+}
+
+// Combines two hashes into one hash
+fn combine_hashes(l: u64, r: u64) -> u64 {
+    let hash = (17 * 37u64).overflowing_add(l).0;
+    hash.overflowing_mul(37).0.overflowing_add(r).0
+}
+
+macro_rules! equal_rows_elem {
+    ($array_type:ident, $l: ident, $r: ident, $left: ident, $right: ident) => {
+        $l.as_any()
+            .downcast_ref::<$array_type>()
+            .unwrap()
+            .value($left)
+            == $r
+                .as_any()
+                .downcast_ref::<$array_type>()
+                .unwrap()
+                .value($right)
+    };
+}
+
+/// Left and right row have equal values
+fn equal_rows(

Review comment:
       This is not vectorized (one row at a time). Could be vectorized in the 
future, checking an array of "matched candidates" instead of 1 by 1.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to