private SchemaElement BuildSchemaElement(Thrift.SchemaElement tse, SchemaElement parent, ParquetOptions formatOptions, Type elementType, string name = null) { Type columnType; if (elementType != null) { columnType = elementType; if (elementType == typeof(IEnumerable)) { Type itemType = TypePrimitive.GetSystemTypeBySchema(tse, formatOptions); Type ienumType = typeof(IEnumerable <>); Type ienumGenericType = ienumType.MakeGenericType(itemType); elementType = itemType; columnType = ienumGenericType; } } else { elementType = TypePrimitive.GetSystemTypeBySchema(tse, formatOptions); columnType = elementType; } var se = new SchemaElement(tse, name, elementType, columnType, null); se.Parent = parent; return(se); }
private SchemaElement BuildMapSchema(ref Thrift.SchemaElement tse, ref int i, bool isRoot, SchemaElement node, ParquetOptions formatOptions) { //tse is followed by map container (REPEATED) and another two elements - key and value Thrift.SchemaElement tseContainer = _fileMeta.Schema[++i]; Thrift.SchemaElement tseKey = _fileMeta.Schema[++i]; Thrift.SchemaElement tseValue = _fileMeta.Schema[++i]; Type keyType = TypePrimitive.GetSystemTypeBySchema(tseKey, formatOptions); Type valueType = TypePrimitive.GetSystemTypeBySchema(tseValue, formatOptions); Type gt = typeof(Dictionary <,>); Type masterType = gt.MakeGenericType(keyType, valueType); //master schema var se = new SchemaElement(tseContainer, tse.Name, masterType, masterType, string.Join(Schema.PathSeparator, tse.Name, tseContainer.Name)); if (!isRoot) { se.Path = node.Parent + Schema.PathSeparator + se.Path; } se.Parent = node; se.IsMap = true; AddFlags(se, tse, tseContainer); //extra schamas var kse = new SchemaElement(tseKey, null, keyType, keyType, null) { Parent = se }; var vse = new SchemaElement(tseValue, null, valueType, valueType, null) { Parent = se }; se.Extra.Add(kse); se.Extra.Add(vse); AddFlags(kse, tseKey); AddFlags(vse, tseValue); tse = tseValue; return(se); }
public static IList Create(SchemaElement schema, ParquetOptions options, bool nullable = false) { Type t = TypePrimitive.GetSystemTypeBySchema(schema, options); return(Create(t, nullable)); }