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

Function hash_array_primitive

datafusion/common/src/hash_utils.rs:217–256  ·  view source on GitHub ↗
(
    array: &PrimitiveArray<T>,
    random_state: &RandomState,
    hashes_buffer: &mut [u64],
    rehash: bool,
)

Source from the content-addressed store, hash-verified

215/// and hashes only the new value (avoiding a separate combine step).
216#[cfg(not(feature = "force_hash_collisions"))]
217fn hash_array_primitive<T>(
218 array: &PrimitiveArray<T>,
219 random_state: &RandomState,
220 hashes_buffer: &mut [u64],
221 rehash: bool,
222) where
223 T: ArrowPrimitiveType<Native: HashValue>,
224{
225 assert_eq!(
226 hashes_buffer.len(),
227 array.len(),
228 "hashes_buffer and array should be of equal length"
229 );
230
231 if array.null_count() == 0 {
232 if rehash {
233 for (hash, &value) in hashes_buffer.iter_mut().zip(array.values().iter()) {
234 let mut hasher = seeded_state(*hash).build_hasher();
235 value.hash_write(&mut hasher);
236 *hash = hasher.finish();
237 }
238 } else {
239 for (hash, &value) in hashes_buffer.iter_mut().zip(array.values().iter()) {
240 *hash = value.hash_one(random_state);
241 }
242 }
243 } else if rehash {
244 for i in array.nulls().unwrap().valid_indices() {
245 let value = unsafe { array.value_unchecked(i) };
246 let mut hasher = seeded_state(hashes_buffer[i]).build_hasher();
247 value.hash_write(&mut hasher);
248 hashes_buffer[i] = hasher.finish();
249 }
250 } else {
251 for i in array.nulls().unwrap().valid_indices() {
252 let value = unsafe { array.value_unchecked(i) };
253 hashes_buffer[i] = value.hash_one(random_state);
254 }
255 }
256}
257
258/// Hashes one array into the `hashes_buffer`
259/// If `rehash==true` this combines the previous hash value in the buffer

Callers

nothing calls this directly

Calls 8

seeded_stateFunction · 0.85
null_countMethod · 0.80
hash_writeMethod · 0.80
hash_oneMethod · 0.80
iterMethod · 0.45
valuesMethod · 0.45
finishMethod · 0.45
nullsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…