/// <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.Count).All(c => saver.IsColumnSavable(schema[c].Type))); ctx.SaveBinaryStream("Schema.idv", w => saver.SaveData(w.BaseStream, noRows, Utils.GetIdentityPermutation(schema.Count))); }
/// <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)); }
protected WritePipe(BinarySaver parent) { Contracts.AssertValue(parent); Parent = parent; }