Open
Conversation
Ngoguey42
reviewed
Nov 15, 2021
|
|
||
| Further, keys must be hashable (with the hash represented as an int), and the implementation even requires that the user specify the number of bits in the hash that are relevant. | ||
|
|
||
| FIXME There is a worrying comment regarding the key hash: "underestimation [of the number of relevant bits] will result in undefined behavior"; most code that uses hashes should still work (albeit very slowly) even if all hashes have the same value. So, this comment is a bit unusual. What happens if hashes collide? What do we do about this? |
There was a problem hiding this comment.
You must be referring to that part of the doc:
Lines 17 to 22 in fe5e962
hash_size is used by the fan to select the bits in the short hash of a keys, depending on the size of the fan.
Overestimating imply that the fan will refer to bits that don't carry informations (typically zeroes).
Underestimating should be fine in my opinion.
Contributor
There was a problem hiding this comment.
Underestimating causes an undefined behaviour because that means the bits selection drops the MSBs, which breaks the order. Having the bit selection preserving the hash order is an important invariant to the fan-out.
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.
High-level doc of Index functioning