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

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

        for (int i = offset; i < offset + length; i++) {
            unsafe.putInt(bytes, (long) index + ARRAY_BYTE_BASE_OFFSET, values[i]);
            index += ARRAY_INT_INDEX_SCALE;
        }
        return index;
    }
@Test
    public static void testSetInts()
    {
        byte[] destination = new byte[POSITIONS_PER_PAGE * ARRAY_INT_INDEX_SCALE];

        int copiedBytes = setInts(destination, 0, IntStream.range(0, POSITIONS_PER_PAGE).toArray(), 0, POSITIONS_PER_PAGE);

        assertEquals(copiedBytes, POSITIONS_PER_PAGE * ARRAY_INT_INDEX_SCALE);
        assertCopied(
                IntStream.range(0, POSITIONS_PER_PAGE).boxed().collect(toImmutableList()),
                destination,
                ARRAY_INT_INDEX_SCALE,
                ByteArrays::getInt);
    }