You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reference implementation as mentioned in the Javadoc of Hashing.murmur3_128(int) (https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp) uses an unsigned 32-bit integer as seed. Since Java only has signed integers, half of all possible seed values are represented as negative values. Within the constructor of Murmur3_128Hasher the seed value is assigned to a long: this.h1 = seed; this.h2 = seed;
Unfortunately, for negative values, this is not equivalent to the reference implementation using unsigned integers. To fix that the two assignment statements need to be changed to this.h1 = seed & 0xFFFFFFFFL; this.h2 = seed & 0xFFFFFFFFL;
The text was updated successfully, but these errors were encountered:
Thanks for bringing this to our attention! At first glance, this inconsistency between the Java implementation and the linked C++ implementation appears to be correct. We'll need to decide what to do here, since people can have persisted the hash values with an explicit negative seed before.
The reference implementation as mentioned in the Javadoc of Hashing.murmur3_128(int) (https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp) uses an unsigned 32-bit integer as seed. Since Java only has signed integers, half of all possible seed values are represented as negative values. Within the constructor of Murmur3_128Hasher the seed value is assigned to a long:
this.h1 = seed; this.h2 = seed;
Unfortunately, for negative values, this is not equivalent to the reference implementation using unsigned integers. To fix that the two assignment statements need to be changed to
this.h1 = seed & 0xFFFFFFFFL; this.h2 = seed & 0xFFFFFFFFL;
The text was updated successfully, but these errors were encountered: