-
Notifications
You must be signed in to change notification settings - Fork 89
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 identity hasher #514
Add identity hasher #514
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some final suggestions otherwise look good to me.
/ok to test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🔥
Thanks! @njones93531
@njones93531 Just FYI, I've updated the PR title since it will become the commit message with squash merge. Using the github keyword |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing this PR! I like that it is small and easy to reason about!
The tag type approach has been abandoned some time ago in many libraries and replaced with specialized type traits, e.g., specializing
In case construction fails, the user has to provide an alternative code path, i.e., a different non-perfect probing scheme. One thing is unclear to me: @esoha-nvidia you mentioned we want the |
You can do it this way if you want but it has the downside that you can no longer default construct the If you make a private constructor that does all the work in the constructor then, as far as I can tell, your factory function is just: std::optional<perfect_hashing> make_perfect_hashing(args) {
try {
return {perfect_hashing(args)};
} catch {
return std::nullopt;
}
} Right? It's kind of a trivial factory fuction, just converting an exception to an optional. Is it pointless? Or, you could make a constructor that never throws and then put the failure logic into the factory. The problem with this is that now you have split-brained code where the creation of the perfect hash is happening partly in the factory and party in the constructor. If you get into a situation where you end up doing some math in the factory just to send it to the constructor and then having to examine that constructor to determine if a valid hash functor was created... I guess that we'll see how it shakes out. Just be prepared for maybe having to put everything into the constructor because you want to avoid split-brained code. And then be prepare to ask yourself, "Why do we even have this factory?"
Hmm, let me think about this... Yes, you're right. There will be some hashers for which Okay, so |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great.
Two final suggestions otherwise the PR is ready to go.
As we discussed offline, discussions and evaluation of the perfect hashing design will be continued in a private repo until it matures.
Co-authored-by: Daniel Jünger <djuenger@nvidia.com> Co-authored-by: Yunsong Wang <yunsongw@nvidia.com>
/ok to test |
/ok to test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the docs accordingly to unblock CI and all looks good.
Contribute to #487
Partially fixes #505