public static int setBytes(byte[] bytes, int index, byte[] values, int offset, int length)
    {
        requireNonNull(bytes, "bytes is null");
        requireNonNull(values, "values is null");

        checkValidRange(index, length, bytes.length);
        checkValidRange(offset, length, values.length);

        // The performance of one copy and two copies (one big chunk at 8 bytes boundary + rest) are about the same.
        unsafe.copyMemory(values, (long) offset + ARRAY_BYTE_BASE_OFFSET, bytes, (long) index + ARRAY_BYTE_BASE_OFFSET, length);
        return index + length;
    }
@Test
    public static void testSetBytes()
    {
        byte[] destination = new byte[POSITIONS_PER_PAGE];

        byte[] source = new byte[POSITIONS_PER_PAGE];
        ThreadLocalRandom.current().nextBytes(source);

        int setBytes = setBytes(destination, 0, source, 0, POSITIONS_PER_PAGE);

        assertEquals(setBytes, POSITIONS_PER_PAGE);
        assertCopied(Bytes.asList(source), destination, ARRAY_BYTE_INDEX_SCALE, MoreByteArrays::getByte);
    }