英文:
Is it possible to replace 32 bit hash function with 64 bit in this case?
问题
我找到了https://github.com/cespare/mph作为一个最小完美哈希函数,但它似乎使用了32位函数(我想要64位的)。有没有办法替换这个函数,并使其与代码的其余部分一起工作?
英文:
I've found https://github.com/cespare/mph as a minimal perfect hash, but it seems that it uses 32 bit function (I want 64 one). Is there a way to replace the function and make it work along with the rest part of the code?
答案1
得分: 3
是的。步骤如下:
- 阅读并理解论文。
- 阅读并理解代码。
- 进行必要的更改。
算法中没有依赖于特定哈希输出大小的内容,因此您可以将其更改为任何您想要的大小,只要您提供的哈希族满足第1.3节的要求即可。
可能只需要在 mph.go
中将所有的 uint32
更改为 uint64
,并用一个新的64位实现替换 murmur.go
;您只需确保新的64位哈希是可靠的。
英文:
Yes. The steps are:
- Read the paper and understand it.
- Read the code and understand it.
- Make the necessary changes.
There's nothing in the algorithm that depends on a specific hash output size, so you can change it to anything you want, as long as the hash family you supply meets the requirements of section 1.3.
Probably it just requires changing all of the uint32
to uint64
in mph.go
, and replacing all of murmur.go
with a new 64-bit implementation; you just have to make sure that that new 64-bit hash is good.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论