Example #1
0
            private static IColumn KeyValueMetadataFromMetadata <T>(ISchema schema, int col, string metadataName)
            {
                Contracts.AssertValue(schema);
                Contracts.Assert(0 <= col && col < schema.ColumnCount);
                var type = schema.GetMetadataTypeOrNull(metadataName, col);

                Contracts.AssertValue(type);
                Contracts.Assert(type.RawType == typeof(T));

                ValueGetter <T> getter = (ref T val) => schema.GetMetadata(metadataName, col, ref val);

                return(RowColumnUtils.GetColumn(MetadataUtils.Kinds.KeyValues, type, getter));
            }
Example #2
0
 /// <summary>
 /// Returns a row that is a deep in-memory copy of an input row. Note that inactive
 /// columns are allowed in this row, and their activity or inactivity will be reflected
 /// in the output row. Note that the deep copy includes a copy of the metadata as well.
 /// </summary>
 /// <param name="row">The input row</param>
 /// <returns>A deep in-memory copy of the input row</returns>
 public static IRow CloneRow(IRow row)
 {
     Contracts.CheckValue(row, nameof(row));
     return(RowColumnUtils.GetRow(null,
                                  Utils.BuildArray(row.Schema.ColumnCount, c => RowColumnUtils.GetColumn(row, c))));
 }