示例#1
0
        private static Node CreateSchemaNode(LogicalTypeFactory logicalTypeFactory, Type type, string name, LogicalType?logicalTypeOverride, int length)
        {
            if (logicalTypeFactory.TryGetParquetTypes(type, out var p))
            {
                var entry = logicalTypeFactory.GetTypesOverride(logicalTypeOverride, p.logicalType, p.physicalType);
                return(new PrimitiveNode(name, p.repetition, entry.logicalType, entry.physicalType, length));
            }

            if (type.IsArray)
            {
                var item = CreateSchemaNode(logicalTypeFactory, type.GetElementType(), "item", logicalTypeOverride, length);
                var list = new GroupNode("list", Repetition.Repeated, new[] { item });

                try
                {
                    return(new GroupNode(name, Repetition.Optional, new[] { list }, LogicalType.List()));
                }
                finally
                {
                    list.Dispose();
                    item.Dispose();
                }
            }

            throw new ArgumentException($"unsupported logical type {type}");
        }
示例#2
0
        /// <summary>
        /// Create a schema node containing all the given columns, using the given logical-type factory.
        /// </summary>
        public static GroupNode CreateSchemaNode(Column[] columns, LogicalTypeFactory logicalTypeFactory, string nodeName = "schema")
        {
            if (columns == null)
            {
                throw new ArgumentNullException(nameof(columns));
            }

            var fields = columns.Select(c => c.CreateSchemaNode(logicalTypeFactory)).ToArray();

            try
            {
                return(new GroupNode(nodeName, Repetition.Required, fields));
            }
            finally
            {
                foreach (var node in fields)
                {
                    node.Dispose();
                }
            }
        }
示例#3
0
 /// <summary>
 /// Create a schema node representing this column with its given properties, using the given logical-type factory.
 /// </summary>
 public Node CreateSchemaNode(LogicalTypeFactory typeFactory)
 {
     return(CreateSchemaNode(typeFactory, LogicalSystemType, Name, LogicalTypeOverride, Length));
 }