Esempio n. 1
0
            public ArrayColumnReader(int rowCount, IClickHouseColumnTypeInfo elementType)
            {
                _rowCount    = rowCount;
                _elementType = elementType;

                _ranges = new List <(int offset, int length)>(_rowCount);
            }
Esempio n. 2
0
 public ArrayColumnWriterDispatcher(string columnName, string columnType, object rows, ClickHouseColumnSettings?columnSettings, IClickHouseColumnTypeInfo elementTypeInfo)
 {
     _columnName      = columnName;
     _columnType      = columnType;
     _rows            = rows;
     _columnSettings  = columnSettings;
     _elementTypeInfo = elementTypeInfo;
 }
Esempio n. 3
0
        public NullableTypeInfo(IClickHouseColumnTypeInfo underlyingType)
        {
            if (underlyingType is NullableTypeInfo)
            {
                throw new ArgumentException("The underlying type can't be nullable.", nameof(underlyingType));
            }

            UnderlyingType  = underlyingType ?? throw new ArgumentNullException(nameof(underlyingType));
            ComplexTypeName = $"{TypeName}({UnderlyingType.ComplexTypeName})";
        }
Esempio n. 4
0
 public MultiDimensionalArrayColumnWriterDispatcher(
     string columnName,
     string columnType,
     IReadOnlyList <Array> rows,
     ClickHouseColumnSettings?columnSettings,
     IClickHouseColumnTypeInfo elementTypeInfo,
     Func <Array, object> dispatchArray)
 {
     _columnName      = columnName;
     _columnType      = columnType;
     _rows            = rows;
     _columnSettings  = columnSettings;
     _elementTypeInfo = elementTypeInfo;
     _dispatchArray   = dispatchArray;
 }
Esempio n. 5
0
            public LowCardinalityColumnReader(int rowCount, IClickHouseColumnTypeInfo baseType)
            {
                _rowCount = rowCount;

                if (baseType is NullableTypeInfo nullableBaseType)
                {
                    if (nullableBaseType.UnderlyingType == null)
                    {
                        throw new ClickHouseException(ClickHouseErrorCodes.TypeNotFullySpecified, $"The type \"{baseType.ComplexTypeName}\" is not fully specified.");
                    }

                    // LowCardinality column stores NULL as the key 0
                    _baseType = nullableBaseType.UnderlyingType;
                }
                else
                {
                    _baseType = baseType;
                }
            }
Esempio n. 6
0
            public override void Format(IClickHouseColumnTypeInfo keyType, IClickHouseColumnTypeInfo valueType, StringBuilder queryStringBuilder, object untypedMap)
            {
                var map = (IReadOnlyDictionary <TKey, TValue>)untypedMap;

                queryStringBuilder.Append("tuple([");
                {
                    var needComma = false;
                    foreach (var(key, _) in map)
                    {
                        if (needComma)
                        {
                            queryStringBuilder.Append(',');
                        }
                        else
                        {
                            needComma = true;
                        }
                        keyType.FormatValue(queryStringBuilder, key);
                    }
                }
                queryStringBuilder.Append("],[");
                {
                    var needComma = false;
                    foreach (var(_, value) in map)
                    {
                        if (needComma)
                        {
                            queryStringBuilder.Append(',');
                        }
                        else
                        {
                            needComma = true;
                        }
                        keyType.FormatValue(queryStringBuilder, value);
                    }
                }
                queryStringBuilder.Append("])");
            }
Esempio n. 7
0
 private ArrayTypeInfo(IClickHouseColumnTypeInfo elementTypeInfo)
 {
     _elementTypeInfo          = elementTypeInfo ?? throw new ArgumentNullException(nameof(elementTypeInfo));
     _exposedElementHeaderSize = GetExposedElementHeaderSize(elementTypeInfo);
     ComplexTypeName           = $"{TypeName}({_elementTypeInfo.ComplexTypeName})";
 }
Esempio n. 8
0
 private LowCardinalityTypeInfo(IClickHouseColumnTypeInfo baseType)
 {
     _baseType       = baseType ?? throw new ArgumentNullException(nameof(baseType));
     ComplexTypeName = $"{TypeName}({_baseType.ComplexTypeName})";
 }
Esempio n. 9
0
            public IClickHouseColumnWriter Dispatch(string columnName, object rows, ClickHouseColumnSettings?columnSettings, IClickHouseColumnTypeInfo underlyingTypeInfo)
            {
                var genericList = (IReadOnlyList <TValue?>)rows;
                var listWrapper = new MappedReadOnlyList <TValue?, TValue>(genericList, item => item ?? default);

                return(underlyingTypeInfo.CreateColumnWriter(columnName, listWrapper, columnSettings));
            }
Esempio n. 10
0
            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);
                }
            }
Esempio n. 11
0
 public NullableColumnReader(int rowCount, IClickHouseColumnTypeInfo underlyingType)
 {
     _rowCount       = rowCount;
     _underlyingType = underlyingType;
 }
Esempio n. 12
0
 public ColumnInfo(string name, IClickHouseColumnTypeInfo typeInfo)
 {
     Name     = name;
     TypeInfo = typeInfo;
 }
Esempio n. 13
0
 public LowCardinalitySkippingColumnReader(int rowCount, IClickHouseColumnTypeInfo baseType)
 {
     _rowCount = rowCount;
     _baseType = baseType;
 }
Esempio n. 14
0
 public LowCardinalityColumnReader(int rowCount, IClickHouseColumnTypeInfo baseType, bool isNullable)
 {
     _rowCount   = rowCount;
     _baseType   = baseType;
     _isNullable = isNullable;
 }
Esempio n. 15
0
 private MapTypeInfo(IClickHouseColumnTypeInfo keyType, IClickHouseColumnTypeInfo valueType, IClickHouseColumnTypeInfo underlyingType)
 {
     _typeArgs       = new KeyValuePair <IClickHouseColumnTypeInfo, IClickHouseColumnTypeInfo>(keyType, valueType);
     ComplexTypeName = $"{TypeName}({keyType.ComplexTypeName}, {valueType.ComplexTypeName})";
     _underlyingType = underlyingType;
 }
Esempio n. 16
0
 public abstract void Format(IClickHouseColumnTypeInfo keyType, IClickHouseColumnTypeInfo valueType, StringBuilder queryStringBuilder, object map);