3 ms·
For a uniformly distributed input set, it doesn't matter how many buckets you have. When you take your modulus, you're going to mix well, regardless of whether
by calambrac 17y ago
For a uniformly distributed input set, it doesn't matter how many buckets you have. When you take your modulus, you're going to mix well, regardless of whether its prime or not. This is what the article (accidentally, apparently) confirms.
The win of using a prime modulus comes when you have a non-uniformly distributed input set (though of course you could craft an especially evil input set). Mod prime is just more likely to produce a more uniform mix across a larger set of input distributions.
Since we're talking about a general-purpose hash table, we can't assume we know anything about our inputs (i.e., that they're uniformly distributed), so we use a prime number of buckets just to up the odds that we come out ahead.
- edw519 17y ago"For a uniformly distributed input set..." A little off-subject, but another good reason to make your primary ids sequential whenever possible. This issue just goes away.