dsxml2169 2019-08-23 07:33 采纳率: 0%
浏览 818

不同语言版本的Murmurhash会得到不同的结果

I've tried three version of murmurhash in java(jedis and guava), go and python. The result of java(guava),go and python version output same hash code but different with java(jedis). All the murmurhash code are shown as follow. I'm confused about the result. I've seen this issue and use Long.reverseBytes in java, and still different with others. So what should I do to make all the output of murmurhash keep same. Thanks~

1. java version(jedis)

java gradle compile group: 'redis.clients', name: 'jedis', version: '3.1.0'

import redis.clients.jedis.util.MurmurHash;

MurmurHash murmurhash = new MurmurHash();
long h = murmurhash.hash("foo");
System.out.println(h);
System.out.println(Long.reverseBytes(h));

output:

-7063922479176959649

6897758107479832477

2. golang version

import "github.com/spaolacci/murmur3"

foo := int64(murmur3.Sum64WithSeed([]byte("foo"), 0x1234ABCD))
fmt.Println(foo)

output:

-5851200325189400636

3. python version

pip install mmh3

import mmh3

foo = mmh3.hash64('foo', seed=0x1234ABCD, signed=True)
print(foo)

output:

-5851200325189400636

4. java(guava)

java gradle compile group: 'com.google.guava', name: 'guava', version: '28.0-jre'

import com.google.common.hash.Hashing

long foo = Hashing.murmur3_128(0x1234ABCD).hashString("foo", charset.forName("UTF-8")).asLong();
System.out.println(foo);

output:

-5851200325189400636
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器