TIL: Using phash2 for data partitioning

1 · Bartosz Górka · Jan. 4, 2023, 6 a.m.
In programming, we often need fairly distribution of data. For example, this can be used when assigning work to one of several running processes and partitioning. Recently, while realizing such a problem, I decided to approach the subject more “mathematically”. Using erlang:phash2/2 you can get the same hash for the same Erlang term regardless of machine architecture and ERTS version. It is possible to indicate the maximum range in the form 0..Range-1. The function should always be used for hash...