Пример #1
0
        /// <summary>
        /// Create a composite schema of both the partitioned columns and the underlying loader columns.
        /// </summary>
        /// <param name="ectx">The exception context.</param>
        /// <param name="cols">The partitioned columns.</param>
        /// <param name="subLoader">The sub loader.</param>
        /// <returns>The resulting schema.</returns>
        private Schema CreateSchema(IExceptionContext ectx, Column[] cols, IDataLoader subLoader)
        {
            Contracts.AssertValue(cols);
            Contracts.AssertValue(subLoader);

            var builder = new SchemaBuilder();

            builder.AddColumns(cols.Select(c => new Schema.DetachedColumn(c.Name, PrimitiveType.FromKind(c.Type.Value), null)));
            var colSchema = builder.GetSchema();

            var subSchema = subLoader.Schema;

            if (subSchema.Count == 0)
            {
                return(colSchema);
            }
            else
            {
                var schemas = new ISchema[]
                {
                    subSchema,
                    colSchema
                };

                return(Schema.Create(new CompositeSchema(schemas)));
            }
        }
Пример #2
0
 /// <summary>
 /// Create a new schema from the given columns.
 /// </summary>
 /// <param name="ectx">The exception context.</param>
 /// <param name="cols">The columns.</param>
 /// <returns>The resulting schema.</returns>
 private ML.Data.Schema CreateSchema(IExceptionContext ectx, Column[] cols)
 {
     Contracts.AssertValue(ectx);
     Contracts.AssertValue(cols);
     var builder = new SchemaBuilder();
     builder.AddColumns(cols.Select(c => new ML.Data.Schema.DetachedColumn(c.Name, c.ColType, null)));
     return builder.GetSchema();
 }
Пример #3
0
        public static Schema Create(IExceptionContext ectx, params KeyValuePair<string, ColumnType>[] columns)
        {
            Contracts.CheckValueOrNull(ectx);
            ectx.CheckValue(columns, nameof(columns));

            var builder = new SchemaBuilder();
            builder.AddColumns(columns.Select(kvp => new Schema.DetachedColumn(kvp.Key, kvp.Value)));
            return builder.GetSchema();
        }