Esempio n. 1
0
        /// <summary>
        /// Save a zero-row dataview that will be used to infer schema information, used in the case
        /// where the tranpsose loader is instantiated with no input streams.
        /// </summary>
        private static void SaveSchema(IHostEnvironment env, ModelSaveContext ctx, Schema schema)
        {
            Contracts.AssertValue(env);

            env.AssertValue(ctx);
            env.AssertValue(schema);

            var noRows = new EmptyDataView(env, schema);

            env.Assert(noRows.GetRowCount() == 0);

            var saverArgs = new BinarySaver.Arguments();

            saverArgs.Silent = true;
            var saver = new BinarySaver(env, saverArgs);

            // We load our schema from what amounts to a binary loader, so all columns should likewise be savable.
            env.Assert(Enumerable.Range(0, schema.ColumnCount).All(c => saver.IsColumnSavable(schema.GetColumnType(c))));
            ctx.SaveBinaryStream("Schema.idv", w => saver.SaveData(w.BaseStream, noRows, Utils.GetIdentityPermutation(schema.ColumnCount)));
        }
Esempio n. 2
0
            /// <summary>
            /// Returns an appropriate generic <c>WritePipe{T}</c> for the given column.
            /// </summary>
            public static WritePipe Create(BinarySaver parent, RowCursor cursor, ColumnCodec col)
            {
                Type writePipeType = typeof(WritePipe <>).MakeGenericType(col.Codec.Type.RawType);

                return((WritePipe)Activator.CreateInstance(writePipeType, parent, cursor, col));
            }
Esempio n. 3
0
 protected WritePipe(BinarySaver parent)
 {
     Contracts.AssertValue(parent);
     Parent = parent;
 }