presto-spi/src/main/java/io/prestosql/spi/block/IntArrayList.java/IntArrayList/grow
class IntArrayList:    private void grow(int newCapacity)
    {
        if (array.length == MAX_ARRAY_SIZE) {
            throw new IllegalStateException("Array reached maximum size");
        }

        if (newCapacity > array.length) {
            int newLength = (int) Math.min(Math.max(2L * (long) array.length, (long) newCapacity), MAX_ARRAY_SIZE);
            array = Arrays.copyOf(array, newLength);
        }
    }