ByteBufferUtils { public static long xxHash(final ByteBuffer byteBuffer) { return LongHashFunction.xx().hashBytes(byteBuffer); } private  ByteBufferUtils(); static String byteBufferToString(final ByteBuffer byteBuffer); static String byteBufferToHex(final ByteBuffer byteBuffer); static String byteBufferToHexAll(final ByteBuffer byteBuffer); static String byteBufferInfo(final ByteBuffer byteBuffer); static String byteBufferToAllForms(final ByteBuffer byteBuffer); static int compare(final ByteBuffer left, final ByteBuffer right); static int compareAsLong(final ByteBuffer left, final ByteBuffer right); static int compareAsLong(final ByteBuffer left, final int leftPos,
                                   final ByteBuffer right, final int rightPos); static int compareAsInt(final ByteBuffer left, final ByteBuffer right); static int compareAsInt(final ByteBuffer left, final int leftPos,
                                   final ByteBuffer right, final int rightPos); static boolean containsPrefix(final ByteBuffer buffer, final ByteBuffer prefixBuffer); static void copy(final ByteBuffer sourceBuffer, final ByteBuffer destBuffer); static ByteBuffer copyToDirectBuffer(final ByteBuffer input); static long xxHash(final ByteBuffer byteBuffer); static int basicHashCode(final ByteBuffer byteBuffer);  }
@Test void testXxHash() { ByteBuffer byteBuffer1 = ByteBuffer.wrap(new byte[]{0, 0, 1, 2, 3, 4, 5, 0, 0}); byteBuffer1.position(2); byteBuffer1.limit(7); LOGGER.info(ByteBufferUtils.byteBufferInfo(byteBuffer1)); ByteBuffer byteBuffer2 = ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5, 0, 0}); byteBuffer2.position(1); byteBuffer2.limit(6); LOGGER.info(ByteBufferUtils.byteBufferInfo(byteBuffer2)); long hash1 = ByteBufferUtils.xxHash(byteBuffer1); long hash2 = ByteBufferUtils.xxHash(byteBuffer2); assertThat(hash1).isEqualTo(hash2); }