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

Function hash_primitive_values

datafusion/spark/src/function/hash/utils.rs:34–59  ·  view source on GitHub ↗
(
    array: &PrimitiveArray<P>,
    hashes: &mut [u64],
    transform: F,
    hash_method: H,
)

Source from the content-addressed store, hash-verified

32/// value into a byte slice before feeding it to `hash_method`.
33#[inline]
34pub(crate) fn hash_primitive_values<P, F, B, H>(
35 array: &PrimitiveArray<P>,
36 hashes: &mut [u64],
37 transform: F,
38 hash_method: H,
39) where
40 P: ArrowPrimitiveType,
41 F: Fn(P::Native) -> B,
42 B: AsRef<[u8]>,
43 H: Fn(B, u64) -> u64,
44{
45 let values = array.values();
46 if array.null_count() == 0 {
47 // Fast path: no nulls, skip null checks
48 for (i, hash) in hashes.iter_mut().enumerate() {
49 *hash = hash_method(transform(values[i]), *hash);
50 }
51 } else {
52 // Slow path: check each row for null
53 for (i, hash) in hashes.iter_mut().enumerate() {
54 if !array.is_null(i) {
55 *hash = hash_method(transform(values[i]), *hash);
56 }
57 }
58 }
59}
60
61/// Hash an array by calling `value_at(array, i)` to produce a byte slice for
62/// each non-null row. Used for byte-slice arrays (Utf8/Binary/FixedSizeBinary

Callers

nothing calls this directly

Calls 3

null_countMethod · 0.80
valuesMethod · 0.45
is_nullMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…