presto-spi/src/main/java/io/prestosql/spi/block/BlockUtil.java/BlockUtil/compactArray
class BlockUtil:    static int[] compactArray(int[] array, int index, int length)
    {
        if (index == 0 && length == array.length) {
            return array;
        }
        return Arrays.copyOfRange(array, index, index + length);
    }