(
array: &UnionArray,
union_fields: &UnionFields,
random_state: &RandomState,
hashes_buffer: &mut [u64],
)
| 742 | /// this simpler approach is preferred. |
| 743 | #[cfg(not(feature = "force_hash_collisions"))] |
| 744 | fn hash_union_array_default( |
| 745 | array: &UnionArray, |
| 746 | union_fields: &UnionFields, |
| 747 | random_state: &RandomState, |
| 748 | hashes_buffer: &mut [u64], |
| 749 | ) -> Result<()> { |
| 750 | let mut child_hashes: HashMap<i8, Vec<u64>> = |
| 751 | HashMap::with_capacity(union_fields.len()); |
| 752 | |
| 753 | // Hash each child array fully |
| 754 | for (type_id, _field) in union_fields.iter() { |
| 755 | let child = array.child(type_id); |
| 756 | let mut child_hash_buffer = vec![0; child.len()]; |
| 757 | create_hashes([child], random_state, &mut child_hash_buffer)?; |
| 758 | |
| 759 | child_hashes.insert(type_id, child_hash_buffer); |
| 760 | } |
| 761 | |
| 762 | // Combine hashes for each row using the appropriate child offset |
| 763 | // For dense unions: value_offset points to the actual position in the child |
| 764 | // For sparse unions: value_offset equals the row index |
| 765 | #[expect(clippy::needless_range_loop)] |
| 766 | for i in 0..array.len() { |
| 767 | let type_id = array.type_id(i); |
| 768 | let child_offset = array.value_offset(i); |
| 769 | |
| 770 | let child_hash = child_hashes.get(&type_id).expect("invalid type_id"); |
| 771 | hashes_buffer[i] = combine_hashes(hashes_buffer[i], child_hash[child_offset]); |
| 772 | } |
| 773 | |
| 774 | Ok(()) |
| 775 | } |
| 776 | |
| 777 | /// Hash a sparse union array. |
| 778 | /// Sparse unions have child arrays with the same length as the union array. |
no test coverage detected
searching dependent graphs…