| 50 | |
| 51 | impl HashIndex { |
| 52 | pub(super) fn build(docs: &[(String, Vec<u8>)], keys: &[&str]) -> Self { |
| 53 | let state = std::collections::hash_map::RandomState::new(); |
| 54 | let mut buckets: std::collections::HashMap<u64, Vec<BucketEntry>> = |
| 55 | std::collections::HashMap::with_capacity(docs.len()); |
| 56 | for (i, (_, value)) in docs.iter().enumerate() { |
| 57 | let (hash, ranges) = hash_join_key(value, keys, &state); |
| 58 | buckets.entry(hash).or_default().push((i, ranges)); |
| 59 | } |
| 60 | Self { buckets, state } |
| 61 | } |
| 62 | |
| 63 | /// Find all doc indices whose key bytes match the probe key. |
| 64 | pub(super) fn probe( |