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

Function hash_list_array

datafusion/common/src/hash_utils.rs:623–671  ·  view source on GitHub ↗
(
    array: &GenericListArray<OffsetSize>,
    random_state: &RandomState,
    hashes_buffer: &mut [u64],
)

Source from the content-addressed store, hash-verified

621
622#[cfg(not(feature = "force_hash_collisions"))]
623fn hash_list_array<OffsetSize>(
624 array: &GenericListArray<OffsetSize>,
625 random_state: &RandomState,
626 hashes_buffer: &mut [u64],
627) -> Result<()>
628where
629 OffsetSize: OffsetSizeTrait,
630{
631 // In case values is sliced, hash only the bytes used by the offsets of this ListArray
632 let first_offset = array.value_offsets().first().cloned().unwrap_or_default();
633 let last_offset = array.value_offsets().last().cloned().unwrap_or_default();
634 let value_bytes_len = (last_offset - first_offset).as_usize();
635 let mut values_hashes = vec![0u64; value_bytes_len];
636 create_hashes(
637 [array
638 .values()
639 .slice(first_offset.as_usize(), value_bytes_len)],
640 random_state,
641 &mut values_hashes,
642 )?;
643
644 if array.null_count() > 0 {
645 for (i, (start, stop)) in array.value_offsets().iter().tuple_windows().enumerate()
646 {
647 if array.is_valid(i) {
648 let hash = &mut hashes_buffer[i];
649 for values_hash in &values_hashes[(*start - first_offset).as_usize()
650 ..(*stop - first_offset).as_usize()]
651 {
652 *hash = combine_hashes(*hash, *values_hash);
653 }
654 }
655 }
656 } else {
657 for ((start, stop), hash) in array
658 .value_offsets()
659 .iter()
660 .tuple_windows()
661 .zip(hashes_buffer.iter_mut())
662 {
663 for values_hash in &values_hashes
664 [(*start - first_offset).as_usize()..(*stop - first_offset).as_usize()]
665 {
666 *hash = combine_hashes(*hash, *values_hash);
667 }
668 }
669 }
670 Ok(())
671}
672
673#[cfg(not(feature = "force_hash_collisions"))]
674fn hash_list_view_array<OffsetSize>(

Callers

nothing calls this directly

Calls 12

create_hashesFunction · 0.85
combine_hashesFunction · 0.85
value_offsetsMethod · 0.80
lastMethod · 0.80
sliceMethod · 0.80
null_countMethod · 0.80
clonedMethod · 0.45
firstMethod · 0.45
as_usizeMethod · 0.45
valuesMethod · 0.45
iterMethod · 0.45
is_validMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…