MCPcopy Create free account
hub / github.com/apache/datafusion / hash_array

Function hash_array

datafusion/common/src/hash_utils.rs:262–301  ·  view source on GitHub ↗
(
    array: &T,
    random_state: &RandomState,
    hashes_buffer: &mut [u64],
    rehash: bool,
)

Source from the content-addressed store, hash-verified

260/// with the new hash using `combine_hashes`
261#[cfg(not(feature = "force_hash_collisions"))]
262fn hash_array<T>(
263 array: &T,
264 random_state: &RandomState,
265 hashes_buffer: &mut [u64],
266 rehash: bool,
267) where
268 T: ArrayAccessor,
269 T::Item: HashValue,
270{
271 assert_eq!(
272 hashes_buffer.len(),
273 array.len(),
274 "hashes_buffer and array should be of equal length"
275 );
276
277 if array.null_count() == 0 {
278 if rehash {
279 for (i, hash) in hashes_buffer.iter_mut().enumerate() {
280 let value = unsafe { array.value_unchecked(i) };
281 *hash = combine_hashes(value.hash_one(random_state), *hash);
282 }
283 } else {
284 for (i, hash) in hashes_buffer.iter_mut().enumerate() {
285 let value = unsafe { array.value_unchecked(i) };
286 *hash = value.hash_one(random_state);
287 }
288 }
289 } else if rehash {
290 for i in array.nulls().unwrap().valid_indices() {
291 let value = unsafe { array.value_unchecked(i) };
292 hashes_buffer[i] =
293 combine_hashes(value.hash_one(random_state), hashes_buffer[i]);
294 }
295 } else {
296 for i in array.nulls().unwrap().valid_indices() {
297 let value = unsafe { array.value_unchecked(i) };
298 hashes_buffer[i] = value.hash_one(random_state);
299 }
300 }
301}
302
303/// Hash a StringView or BytesView array
304///

Callers

nothing calls this directly

Calls 4

combine_hashesFunction · 0.85
null_countMethod · 0.80
hash_oneMethod · 0.80
nullsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…