public ArrayColumnWriter(string columnType, ArrayLinearizedList <T> rows, IClickHouseColumnWriter elementColumnWriter) { _rows = rows; _elementColumnWriter = elementColumnWriter; ColumnName = elementColumnWriter.ColumnName; ColumnType = columnType; }
public MapColumnWriter(IClickHouseColumnWriter underlyingWriter) { const string typeNameStart = "Array(Tuple", typeNameEnd = ")"; var typeName = underlyingWriter.ColumnType; if (!typeName.StartsWith(typeNameStart) || !typeName.EndsWith(typeNameEnd)) { throw new ClickHouseException(ClickHouseErrorCodes.InternalError, $"Internal error. The name of the type \"{typeName}\" doesn't match to the expected pattern \"{Regex.Escape(typeNameStart)}.*{Regex.Escape(typeNameEnd)}\"."); } ColumnType = "Map" + typeName[typeNameStart.Length..^ typeNameEnd.Length];
public NullableColumnWriter(string columnName, string columnType, IReadOnlyList <T> rows, ClickHouseColumnSettings?columnSettings, IClickHouseColumnTypeInfo underlyingTypeInfo) { if (underlyingTypeInfo == null) { throw new ArgumentNullException(nameof(underlyingTypeInfo)); } _rows = rows ?? throw new ArgumentNullException(nameof(rows)); ColumnName = columnName ?? throw new ArgumentNullException(nameof(columnName)); ColumnType = columnType ?? throw new ArgumentNullException(nameof(columnType)); if (typeof(T).IsValueType && typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(Nullable <>)) { var valueType = typeof(T).GetGenericArguments()[0]; var dispatcherType = typeof(ValueOrDefaultListDispatcher <>).MakeGenericType(valueType); var columnDispatcher = (IValueOrDefaultListDispatcherBase)Activator.CreateInstance(dispatcherType) !; _internalColumnWriter = columnDispatcher.Dispatch(columnName, rows, columnSettings, underlyingTypeInfo); } else { _internalColumnWriter = underlyingTypeInfo.CreateColumnWriter(columnName, rows, columnSettings); } }