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
Generic Hashers #236
base: master
Are you sure you want to change the base?
Generic Hashers #236
Conversation
Can I ask, is anything blocking advancement of this feature? Can I help? |
I haven't reviewed this because it's WIP, @bhgomes if you're still interested in this, could you resolve merge conflicts and make it ready for review? |
@JohnTitor It seems like
Do think this can/should be a feature of the |
This is a draft proposal for a generic hasher interface (#88) for this library.
How this Works
PhfHasher
traitPhfHasher
parameter to maps/setsFmtConstPath
trait to hookPhfHasher
intophf_codegen
quote::ToTokens
trait to hookPhfHasher
intophf_macros
Note on Point 1
Right now, the
PhfHasher
trait is only responsible for the initial PHF distribution (think SipHasher keys) and the actual hashing (computingHashes
object). The PHF generation algorithm is still the same as before, but if it makes more sense to use a separate generation algorithm for each hashing algorithm, then we should replacePhfHasher
with something like the following which is a little simpler than what the current draft proposes:where
HashState
andHashes
are the computed map/displacements and index respectively.Also, in this PR,
phf_generator
is removed since it only contains the generation algorithm which should live closer toPhfHasher
and eventually could be part of it.Note on Point 4
Right now, the macro interface itself has not changed so it's not possible with this current draft to use custom hashers with macros. To enable this, we would need to have to extend the macro interface or have some sort of type inference to detect the hasher. It's still not clear to me how we should do this.