Hash the raw bytes using a provided `RandomState` for consistent hashing within a single query (all docs hashed with the same seed).
(
buf: &[u8],
range: (usize, usize),
state: &std::collections::hash_map::RandomState,
)
| 30 | /// Hash the raw bytes using a provided `RandomState` for consistent hashing |
| 31 | /// within a single query (all docs hashed with the same seed). |
| 32 | pub fn hash_field_bytes_with( |
| 33 | buf: &[u8], |
| 34 | range: (usize, usize), |
| 35 | state: &std::collections::hash_map::RandomState, |
| 36 | ) -> u64 { |
| 37 | let slice = match buf.get(range.0..range.1) { |
| 38 | Some(s) => s, |
| 39 | None => return 0, |
| 40 | }; |
| 41 | let mut hasher = state.build_hasher(); |
| 42 | hasher.write(slice); |
| 43 | hasher.finish() |
| 44 | } |
| 45 | |
| 46 | /// Compare two MessagePack values by their decoded content. |
| 47 | /// |