/// <summary> /// Returns the <see cref="DataViewSchema"/> which would be produced by the transformer applied to /// an input data with schema <paramref name="inputSchema"/>. /// </summary> public DataViewSchema GetOutputSchema(DataViewSchema inputSchema) { _host.CheckValue(inputSchema, nameof(inputSchema)); var rowToRow = new RowToRowMapper(_host, this, new EmptyDataView(_host, inputSchema)); return(rowToRow.OutputSchema); }
public Cursor(RowToRowMapper parent, DataViewRowCursor input, bool[] active) : base(parent.Host, input) { Ch.AssertValue(parent); Ch.Assert(active == null || active.Length == parent.OutputSchema.Count); _parent = parent; _active = active; _getters = new Delegate[parent._parent.AddedSchema.Columns.Length]; var dstRow = new DataViewConstructionUtils.InputRow <TDst>(_parent.Host, _parent._parent.AddedSchema); IRowReadableAs <TSrc> inputRow = _parent._typedSrc.GetRow(input); TSrc src = new TSrc(); TState state = new TState(); TDst dst = new TDst(); _parent._parent._stateInitAction(state); long lastServedPosition = -1; Action refresh = () => { if (lastServedPosition != input.Position) { inputRow.FillValues(src); _parent._parent._mapAction(src, dst, state); dstRow.ExtractValues(dst); lastServedPosition = input.Position; } }; for (int i = 0; i < active.Length; i++) { var iinfo = _parent._bindings.MapColumnIndex(out var isSrc, i); if (isSrc) { continue; } _getters[iinfo] = Utils.MarshalInvoke(_parent.GetDstGetter <int>, _parent._bindings.Schema[i].Type.RawType, dstRow, _parent._bindings.Schema[i].Name, refresh); } }