OpenHFT / Zero-Allocation-Hashing

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

Endianness and hashLong #66

Closed svladykin closed 3 years ago

svladykin commented 3 years ago

I see that hashLong rotates input on Big Endian platforms with Primitives.nativeToLittleEndian:

https://github.com/OpenHFT/Zero-Allocation-Hashing/blob/303f1a5dba00af1f5482b68e5f3884924bdfe620/src/main/java/net/openhft/hashing/XxHash.java#L155

Do I understand correct that hashLong(1L) will not return the same result on Big and Little Endian platforms?

gzm55 commented 3 years ago

The portability is defined by the hash algorithm, here your example xxhash, not by the interface hashLong(). You can also find the portability description in the javadoc of zah for every implemented hash algorithms.