Hash the raw bytes of a MessagePack value at `range` within `buf`. Uses a fast non-cryptographic hash suitable for hash joins and GROUP BY. For canonical-encoded documents (integers in smallest form, sorted keys), semantically equal values produce identical byte sequences and thus identical hashes.
(buf: &[u8], range: (usize, usize))
| 17 | /// semantically equal values produce identical byte sequences and thus |
| 18 | /// identical hashes. |
| 19 | pub fn hash_field_bytes(buf: &[u8], range: (usize, usize)) -> u64 { |
| 20 | let slice = match buf.get(range.0..range.1) { |
| 21 | Some(s) => s, |
| 22 | None => return 0, |
| 23 | }; |
| 24 | let hasher_builder = std::collections::hash_map::RandomState::new(); |
| 25 | let mut hasher = hasher_builder.build_hasher(); |
| 26 | hasher.write(slice); |
| 27 | hasher.finish() |
| 28 | } |
| 29 | |
| 30 | /// Hash the raw bytes using a provided `RandomState` for consistent hashing |
| 31 | /// within a single query (all docs hashed with the same seed). |