|
8 | 8 |
|
9 | 9 | namespace Microsoft.ML.Runtime.Data
|
10 | 10 | {
|
11 |
| - /// <summary> |
12 |
| - /// This contains information about a column in an <see cref="IDataView"/>. It is essentially a convenience cache |
13 |
| - /// containing the name, column index, and column type for the column. The intended usage is that users of <see cref="RoleMappedSchema"/> |
14 |
| - /// will have a convenient method of getting the index and type without having to separately query it through the <see cref="Schema"/>, |
15 |
| - /// since practically the first thing a consumer of a <see cref="RoleMappedSchema"/> will want to do once they get a mappping is get |
16 |
| - /// the type and index of the corresponding column. |
17 |
| - /// </summary> |
18 |
| - public sealed class ColumnInfo |
19 |
| - { |
20 |
| - public readonly string Name; |
21 |
| - public readonly int Index; |
22 |
| - public readonly ColumnType Type; |
23 |
| - |
24 |
| - private ColumnInfo(string name, int index, ColumnType type) |
25 |
| - { |
26 |
| - Name = name; |
27 |
| - Index = index; |
28 |
| - Type = type; |
29 |
| - } |
30 |
| - |
31 |
| - /// <summary> |
32 |
| - /// Tries to create a ColumnInfo for the column with the given name in the given schema. Returns |
33 |
| - /// false if the name doesn't map to a column. |
34 |
| - /// </summary> |
35 |
| - public static bool TryCreateFromName(Schema schema, string name, out ColumnInfo colInfo) |
36 |
| - { |
37 |
| - Contracts.CheckValue(schema, nameof(schema)); |
38 |
| - Contracts.CheckNonEmpty(name, nameof(name)); |
39 |
| - |
40 |
| - colInfo = null; |
41 |
| - if (!schema.TryGetColumnIndex(name, out int index)) |
42 |
| - return false; |
43 |
| - |
44 |
| - colInfo = new ColumnInfo(name, index, schema[index].Type); |
45 |
| - return true; |
46 |
| - } |
47 |
| - |
48 |
| - /// <summary> |
49 |
| - /// Creates a ColumnInfo for the column with the given column index. Note that the name |
50 |
| - /// of the column might actually map to a different column, so this should be used with care |
51 |
| - /// and rarely. |
52 |
| - /// </summary> |
53 |
| - public static ColumnInfo CreateFromIndex(Schema schema, int index) |
54 |
| - { |
55 |
| - Contracts.CheckValue(schema, nameof(schema)); |
56 |
| - Contracts.CheckParam(0 <= index && index < schema.Count, nameof(index)); |
57 |
| - |
58 |
| - return new ColumnInfo(schema[index].Name, index, schema[index].Type); |
59 |
| - } |
60 |
| - } |
61 |
| - |
62 | 11 | /// <summary>
|
63 | 12 | /// Encapsulates an <see cref="Schema"/> plus column role mapping information. The purpose of role mappings is to
|
64 | 13 | /// provide information on what the intended usage is for. That is: while a given data view may have a column named
|
|
0 commit comments