OpenHFT / Zero-Allocation-Hashing

Zero-allocation hashing for Java
Apache License 2.0
793 stars 136 forks source link

murmur3: different output for hashChars() and hashBytes() #80

Closed onlynishant closed 1 year ago

onlynishant commented 1 year ago

Hi,

I am not sure if I am using murmur3 function correctly but the result seems different for hashChars() and hashBytes()

String input = "abc123";
System.out.println(LongHashFunction.murmur_3().hashChars(input));
System.out.println(LongHashFunction.murmur_3().hashBytes(input.getBytes()));

Output:

-4878457159164508227
-7432123028918728600

Which function should be used for String inputs? Shouldn't both functions produce the same result?

Addition question: How can I get the equivalent output (128-bit hex string) of this:

Hashing.murmur3_128().newHasher().putString(s, Charsets.UTF_8).hash().toString()
alamar commented 1 year ago

Please use Stack Overflow to ask questions.

onlynishant commented 1 year ago

I couldn't find the appropriate tag so I posted it here. Posted on StackOverflow: https://stackoverflow.com/questions/76455309/zero-allocation-hashing-murmur3-hashchars-and-hashbytes-produce-different-o