rishabhdaim commented on code in PR #2461:
URL: https://github.com/apache/jackrabbit-oak/pull/2461#discussion_r2290658592


##########
oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/standby/codec/ResponseDecoder.java:
##########
@@ -203,11 +205,21 @@ private static void decodeGetReferencesResponse(int 
length, ByteBuf in, List<Obj
     }
 
     private static long hash(byte[] data) {
-        return 
Hashing.murmur3_32().newHasher().putBytes(data).hash().padToLong();
+        return Integer.toUnsignedLong(MurmurHash3.hash32x86(data));
     }
 
     private static long hash(byte mask, long blobLength, byte[] data) {
-        return 
Hashing.murmur3_32().newHasher().putByte(mask).putLong(blobLength).putBytes(data).hash().padToLong();
+
+        final ByteBuffer byteBuffer = ByteBuffer.allocate(1 + 8 + data.length)
+                .order(ByteOrder.LITTLE_ENDIAN)  // To align with Guava that 
uses Little Endianess
+                .put(mask)
+                .putLong(blobLength)
+                .put(data);
+        byteBuffer.flip();  // Reset position to start to read data from 
beginning
+        final byte[] bytes = new byte[byteBuffer.limit()];
+        byteBuffer.get(bytes);

Review Comment:
   Yes, it can be used, the above test passes with `ByteBuffer#array()` as well.
   
   Reason for not using it is to avoid any uninitialized values to interfere 
with hash calculation i.e. the default values in `ByteBuffer`.
   
   It is working because of we are initializing the ByteBuffer with exact size 
and the `ByteBuffer#flip()` sets the `limit` value to the end of bytebuffer to 
avoid reading un-initialized values. (where it has been filled).



-- 
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: oak-dev-unsubscr...@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to