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

Function hash_union_array

datafusion/common/src/hash_utils.rs:713–732  ·  view source on GitHub ↗
(
    array: &UnionArray,
    random_state: &RandomState,
    hashes_buffer: &mut [u64],
)

Source from the content-addressed store, hash-verified

711
712#[cfg(not(feature = "force_hash_collisions"))]
713fn hash_union_array(
714 array: &UnionArray,
715 random_state: &RandomState,
716 hashes_buffer: &mut [u64],
717) -> Result<()> {
718 let DataType::Union(union_fields, _mode) = array.data_type() else {
719 unreachable!()
720 };
721
722 if array.is_dense() {
723 // Dense union: children only contain values of their type, so they're already compact.
724 // Use the default hashing approach which is efficient for dense unions.
725 hash_union_array_default(array, union_fields, random_state, hashes_buffer)
726 } else {
727 // Sparse union: each child has the same length as the union array.
728 // Optimization: only hash the elements that are actually referenced by type_ids,
729 // instead of hashing all K*N elements (where K = num types, N = array length).
730 hash_sparse_union_array(array, union_fields, random_state, hashes_buffer)
731 }
732}
733
734/// Default hashing for union arrays - hashes all elements of each child array fully.
735///

Callers

nothing calls this directly

Calls 3

hash_union_array_defaultFunction · 0.85
hash_sparse_union_arrayFunction · 0.85
data_typeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…