public static int compareRanges(byte[] left, int leftOffset, int leftLength, byte[] right, int rightOffset, int rightLength)
    {
        long leftAddress = ARRAY_BYTE_BASE_OFFSET + leftOffset;
        long rightAddress = ARRAY_BYTE_BASE_OFFSET + rightOffset;

        int lengthToCompare = min(leftLength, rightLength);
        while (lengthToCompare >= SIZE_OF_LONG) {
            long leftLong = unsafe.getLong(left, leftAddress);
            long rightLong = unsafe.getLong(right, rightAddress);

            if (leftLong != rightLong) {
                return longBytesToLong(leftLong) < longBytesToLong(rightLong) ? -1 : 1;
            }

            leftAddress += SIZE_OF_LONG;
            rightAddress += SIZE_OF_LONG;
            lengthToCompare -= SIZE_OF_LONG;
        }

        while (lengthToCompare > 0) {
            int compareResult = compareUnsignedBytes(unsafe.getByte(left, leftAddress), unsafe.getByte(right, rightAddress));
            if (compareResult != 0) {
                return compareResult;
            }
            leftAddress++;
            rightAddress++;
            lengthToCompare--;
        }

        return Integer.compare(leftLength, rightLength);
    }
@Test
    public void testCompareRanges()
    {
        assertEquals(compareRanges("abcdefghij".getBytes(), 0, 10, "abcdefghij".getBytes(), 0, 10), 0);
        assertEquals(compareRanges("123abcdefghij".getBytes(), 3, 10, "abcdefghij".getBytes(), 0, 10), 0);
    }