rishabhdaim commented on PR #2461:
URL: https://github.com/apache/jackrabbit-oak/pull/2461#issuecomment-3209320198
Checked the exact outputs from Guava & Apache by following code.
`byte mask = (byte) 0xFF;
long length = 12345678987654332L;
byte[] data = "data".getBytes();
// Guava implementation
Hasher hasher = Hashing.murmur3_32().newHasher();
long guavaResult =
hasher.putByte(mask).putLong(length).putBytes(data).hash().padToLong();
// Commons implementation - use the right byteBuffer size and byte order
ByteBuffer byteBuffer = ByteBuffer.allocate(1 + 8 + data.length)
.order(ByteOrder.LITTLE_ENDIAN) // Important for long values
.put(mask)
.putLong(length)
.put(data);
byteBuffer.flip(); // Reset position to start
byte[] bytes = new byte[byteBuffer.limit()];
byteBuffer.get(bytes);
long commonsResult =
Integer.toUnsignedLong(MurmurHash3.hash32x86(bytes));
Assert.assertEquals(guavaResult, commonsResult);`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]