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

Function hash_run_array_inner

datafusion/common/src/hash_utils.rs:876–944  ·  view source on GitHub ↗
(
    array: &RunArray<R>,
    random_state: &RandomState,
    hashes_buffer: &mut [u64],
)

Source from the content-addressed store, hash-verified

874#[inline(never)]
875#[cfg(not(feature = "force_hash_collisions"))]
876fn hash_run_array_inner<
877 R: RunEndIndexType,
878 const HAS_NULL_VALUES: bool,
879 const REHASH: bool,
880>(
881 array: &RunArray<R>,
882 random_state: &RandomState,
883 hashes_buffer: &mut [u64],
884) -> Result<()> {
885 // We find the relevant runs that cover potentially sliced arrays, so we can only hash those
886 // values. Then we find the runs that refer to the original runs and ensure that we apply
887 // hashes correctly to the sliced, whether sliced at the start, end, or both.
888 let array_offset = array.offset();
889 let array_len = array.len();
890
891 if array_len == 0 {
892 return Ok(());
893 }
894
895 let run_ends = array.run_ends();
896 let run_ends_values = run_ends.values();
897 let values = array.values();
898
899 let start_physical_index = array.get_start_physical_index();
900 // get_end_physical_index returns the inclusive last index, but we need the exclusive range end
901 // for the operations we use below.
902 let end_physical_index = array.get_end_physical_index() + 1;
903
904 let sliced_values = values.slice(
905 start_physical_index,
906 end_physical_index - start_physical_index,
907 );
908 let mut values_hashes = vec![0u64; sliced_values.len()];
909 create_hashes(
910 std::slice::from_ref(&sliced_values),
911 random_state,
912 &mut values_hashes,
913 )?;
914
915 let mut start_in_slice = 0;
916 for (adjusted_physical_index, &absolute_run_end) in run_ends_values
917 [start_physical_index..end_physical_index]
918 .iter()
919 .enumerate()
920 {
921 let absolute_run_end = absolute_run_end.as_usize();
922 let end_in_slice = (absolute_run_end - array_offset).min(array_len);
923
924 if HAS_NULL_VALUES && sliced_values.is_null(adjusted_physical_index) {
925 start_in_slice = end_in_slice;
926 continue;
927 }
928
929 let value_hash = values_hashes[adjusted_physical_index];
930 let run_slice = &mut hashes_buffer[start_in_slice..end_in_slice];
931
932 if REHASH {
933 for hash in run_slice.iter_mut() {

Callers

nothing calls this directly

Calls 10

create_hashesFunction · 0.85
combine_hashesFunction · 0.85
sliceMethod · 0.80
offsetMethod · 0.45
lenMethod · 0.45
valuesMethod · 0.45
iterMethod · 0.45
as_usizeMethod · 0.45
minMethod · 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…