@Override
    @SuppressWarnings("unchecked")
    public ClickHouseArraySequence allocate(int length, Class<?> clazz, int level) {
        if (length < 1) {
            // resetToNullOrEmpty / resetToDefault will replace the value to Object[0]
            if (!isNullOrEmpty() || getValue().getClass().getComponentType() != clazz) {
                set((T[]) (clazz.isPrimitive()
                        ? ClickHouseValues.createPrimitiveArray(clazz, 0, level)
                        : ClickHouseValues.createObjectArray(clazz, 0, level)));
            }
        } else {
            set((T[]) (clazz.isPrimitive()
                    ? ClickHouseValues.createPrimitiveArray(clazz, length, level)
                    : ClickHouseValues.createObjectArray(clazz, length, level)));
        }
        return this;
    }
Update value of the given object or create a new instance if {@code ref} is
null.

@param <T>   type of element
@param ref   object to update, could be null
@param value value
@return same object as {@code ref} or a new instance if it's null
clickhouse-data/src/main/java/com/clickhouse/data/value/ClickHouseArrayValue.java