Skip to main content

Module string_hash

Module string_hash 

Source
Expand description

String-dim hashing helper shared between curve normalization and tile-index bucketing.

Both super::normalize (when projecting String coords onto a space-filling curve) and crate::tile::layout (when bucketing String coords into tile indices) need the same per-process mapping from a string to an integer. Centralising it here keeps their assignments consistent within a process and gives a single site to swap for sort-preserving codes later.

RandomState is per-process; bucket assignments are NOT stable across restarts. Future work may upgrade to a deterministic dictionary code.

Functions§

hash_string_masked
Hash s into the range [0, bound] (inclusive) by masking with bound. Caller passes bound = (1 << bits) - 1 for power-of-two curve buckets, or extent - 1 style values for tile bucketing (where bound + 1 is a power of two); for arbitrary bound, callers should use hash_string_modulo instead.
hash_string_modulo
Hash s into [0, modulus) via modulo. Used by tile-index bucketing where the extent isn’t necessarily a power of two.