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

Function hash_struct_array

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

Source from the content-addressed store, hash-verified

540
541#[cfg(not(feature = "force_hash_collisions"))]
542fn hash_struct_array(
543 array: &StructArray,
544 random_state: &RandomState,
545 hashes_buffer: &mut [u64],
546) -> Result<()> {
547 let nulls = array.nulls();
548 let row_len = array.len();
549
550 // Create hashes for each row that combines the hashes over all the column at that row.
551 let mut values_hashes = vec![0u64; row_len];
552 create_hashes(array.columns(), random_state, &mut values_hashes)?;
553
554 // Separate paths to avoid allocating Vec when there are no nulls
555 if let Some(nulls) = nulls {
556 for i in nulls.valid_indices() {
557 let hash = &mut hashes_buffer[i];
558 *hash = combine_hashes(*hash, values_hashes[i]);
559 }
560 } else {
561 for i in 0..row_len {
562 let hash = &mut hashes_buffer[i];
563 *hash = combine_hashes(*hash, values_hashes[i]);
564 }
565 }
566
567 Ok(())
568}
569
570// only adding this `cfg` b/c this function is only used with this `cfg`
571#[cfg(not(feature = "force_hash_collisions"))]

Callers

nothing calls this directly

Calls 5

create_hashesFunction · 0.85
combine_hashesFunction · 0.85
columnsMethod · 0.80
nullsMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…