MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / hash_field_bytes_with

Function hash_field_bytes_with

nodedb-query/src/msgpack_scan/compare.rs:32–44  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

30/// Hash the raw bytes using a provided `RandomState` for consistent hashing
31/// within a single query (all docs hashed with the same seed).
32pub 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///

Callers 2

Calls 4

build_hasherMethod · 0.80
getMethod · 0.45
writeMethod · 0.45
finishMethod · 0.45

Tested by 2