在这种情况下,是否可以用64位哈希函数替换32位哈希函数?

huangapple go评论91阅读模式
英文:

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. 阅读并理解论文。
  2. 阅读并理解代码。
  3. 进行必要的更改。

算法中没有依赖于特定哈希输出大小的内容,因此您可以将其更改为任何您想要的大小,只要您提供的哈希族满足第1.3节的要求即可。

可能只需要在 mph.go 中将所有的 uint32 更改为 uint64,并用一个新的64位实现替换 murmur.go;您只需确保新的64位哈希是可靠的。

英文:

Yes. The steps are:

  1. Read the paper and understand it.
  2. Read the code and understand it.
  3. 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.

huangapple
  • 本文由 发表于 2021年9月15日 23:08:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/69195655.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定