Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a custom number of shards for the map #70

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kahuang
Copy link

@kahuang kahuang commented Aug 13, 2018

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

@CanoeFZH
Copy link

CanoeFZH commented Aug 14, 2018

I have same idea with you that shard number matters. #71

@benitogf
Copy link

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

@westofpluto
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants