concurrent-map
concurrent-map copied to clipboard
Add support for a custom number of shards for the map
This adds a new constructor to the ConcurrentMap that allows the user to pass in the number of shards we should shard the map to
I have same idea with you that shard number matters. https://github.com/orcaman/concurrent-map/issues/71
if you change the shard count dont you have to change the hash function params too? https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV_hash_parameters
@benitogf No, not unless you create a huge number of shards. The FNV32 hash function just creates a 32 bit hash, which is a number between 0 and 4.29 billion. The code mods this hash by the number of shards, so if you used 100 or 200 shards you would still likely get good dispersion of the keys between the shards. Of course, if you want 4 billion shards (not recommended) then yes you should probably use a different hashing function like FNV128 etc.