Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

murmurhash3 128bit gives wrong result on big-endian platform #31

Open
GoogleCodeExporter opened this issue Apr 3, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

string "str_hash_mmh"

should give mmh3_128 value

EBC36FB5EAEF57B81E12217B6E10C8B1 (x64 Linux/Solaris/Windows/etc)

while for big-endian machines it gives

B857EFEAB56FC3EBB1C8106E7B21121E (SPARC Solaris)


Original issue reported on code.google.com by alexandr.ustinov on 5 Dec 2014 at 4:35

@GoogleCodeExporter
Copy link
Author

The fix is very simple, as reference we could start from this code

https://github.com/hideo55/node-murmurhash3/blob/master/src/MurmurHash3.cpp

see function getblock(), for BIG_ENDIAN it should return swapped bytes, and 
final rows, 

   ((uint64_t*) out)[0] = h1;
    ((uint64_t*) out)[1] = h2;

for BIG_ENDIAN platform also should be swapped:

   ((uint64_t*) out)[0] =  BYTESWAP64(h1);
    ((uint64_t*) out)[1] =  BYTESWAP64(h2);

as result I've got the same values for both platforms.

Original comment by alexandr.ustinov on 8 Dec 2014 at 5:28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant