Rich-T-kid commented on code in PR #27025:
URL: https://github.com/apache/datafusion/pull/27025#discussion_r4602774438


##########
datafusion/common/src/hash_utils.rs:
##########
@@ -544,6 +570,63 @@ fn hash_generic_byte_view_array<T: ByteViewType>(
     }
 }
 
+/// Scatters non-null dictionary hashes in independent lanes to overlap 
key-indexed loads.
+#[cfg(not(feature = "force_hash_collisions"))]
+#[inline(always)]
+fn scatter_non_null_dictionary<K: ArrowDictionaryKeyType, const MULTI_COL: 
bool>(
+    array: &DictionaryArray<K>,
+    dict_hashes: &[u64],
+    hashes: &mut [u64],
+) {
+    const LANES: usize = 8;
+    let keys = array.keys().values();
+    assert_eq!(
+        dict_hashes.len(),
+        array.values().len(),
+        "dictionary hashes must cover every dictionary value"
+    );
+    assert!(
+        hashes.len() <= keys.len(),
+        "dictionary scatter requires at least one key per hash slot"
+    );
+    let keys = &keys[..hashes.len()];
+
+    let (key_chunks, key_tail) = keys.as_chunks::<LANES>();
+    let (hash_chunks, hash_tail) = hashes.as_chunks_mut::<LANES>();
+    for (keys, hashes) in key_chunks.iter().zip(hash_chunks) {
+        let gathered: [u64; LANES] = std::array::from_fn(|lane| unsafe {

Review Comment:
   Switched these lookups to safe indexing.



##########
datafusion/common/src/hash_utils.rs:
##########
@@ -544,6 +570,63 @@ fn hash_generic_byte_view_array<T: ByteViewType>(
     }
 }
 
+/// Scatters non-null dictionary hashes in independent lanes to overlap 
key-indexed loads.
+#[cfg(not(feature = "force_hash_collisions"))]
+#[inline(always)]
+fn scatter_non_null_dictionary<K: ArrowDictionaryKeyType, const MULTI_COL: 
bool>(
+    array: &DictionaryArray<K>,
+    dict_hashes: &[u64],
+    hashes: &mut [u64],
+) {
+    const LANES: usize = 8;
+    let keys = array.keys().values();
+    assert_eq!(
+        dict_hashes.len(),
+        array.values().len(),
+        "dictionary hashes must cover every dictionary value"
+    );
+    assert!(

Review Comment:
   Moved the prefix-length check to the shared dictionary dispatcher.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to