Add support for a custom number of shards for the map#70
Open
kahuang wants to merge 2 commits intoorcaman:masterfrom
Open
Add support for a custom number of shards for the map#70kahuang wants to merge 2 commits intoorcaman:masterfrom
kahuang wants to merge 2 commits intoorcaman:masterfrom
Conversation
Add support for a custom number of shards
|
I have same idea with you that shard number matters. #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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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