@@ -69,80 +69,6 @@ public override bool IsColumnActive(int col)
69
69
}
70
70
}
71
71
72
- /// <summary>
73
- /// An <see cref="ISchema"/> that takes all column names and types as constructor parameters.
74
- /// The columns do not have metadata.
75
- /// </summary>
76
- public abstract class SimpleSchemaBase : ISchema
77
- {
78
- protected readonly IExceptionContext Ectx ;
79
- private readonly string [ ] _names ;
80
- protected readonly ColumnType [ ] Types ;
81
- protected readonly Dictionary < string , int > ColumnNameMap ;
82
-
83
- public int ColumnCount => Types . Length ;
84
-
85
- protected SimpleSchemaBase ( IExceptionContext ectx , params KeyValuePair < string , ColumnType > [ ] columns )
86
- {
87
- Contracts . CheckValueOrNull ( ectx ) ;
88
- Ectx = ectx ;
89
- Ectx . CheckValue ( columns , nameof ( columns ) ) ;
90
-
91
- _names = new string [ columns . Length ] ;
92
- Types = new ColumnType [ columns . Length ] ;
93
- ColumnNameMap = new Dictionary < string , int > ( ) ;
94
- for ( int i = 0 ; i < columns . Length ; i ++ )
95
- {
96
- _names [ i ] = columns [ i ] . Key ;
97
- Types [ i ] = columns [ i ] . Value ;
98
- if ( ColumnNameMap . ContainsKey ( columns [ i ] . Key ) )
99
- throw ectx . ExceptParam ( nameof ( columns ) , $ "Duplicate column name: '{ columns [ i ] . Key } '") ;
100
- ColumnNameMap [ columns [ i ] . Key ] = i ;
101
- }
102
- }
103
-
104
- public bool TryGetColumnIndex ( string name , out int col )
105
- {
106
- return ColumnNameMap . TryGetValue ( name , out col ) ;
107
- }
108
-
109
- public string GetColumnName ( int col )
110
- {
111
- Ectx . CheckParam ( 0 <= col && col < ColumnCount , nameof ( col ) ) ;
112
- return _names [ col ] ;
113
- }
114
-
115
- public ColumnType GetColumnType ( int col )
116
- {
117
- Ectx . CheckParam ( 0 <= col && col < ColumnCount , nameof ( col ) ) ;
118
- return Types [ col ] ;
119
- }
120
-
121
- public IEnumerable < KeyValuePair < string , ColumnType > > GetMetadataTypes ( int col )
122
- {
123
- Ectx . Assert ( 0 <= col && col < ColumnCount ) ;
124
- return GetMetadataTypesCore ( col ) ;
125
- }
126
-
127
- protected abstract IEnumerable < KeyValuePair < string , ColumnType > > GetMetadataTypesCore ( int col ) ;
128
-
129
- public ColumnType GetMetadataTypeOrNull ( string kind , int col )
130
- {
131
- Ectx . CheckParam ( 0 <= col && col < ColumnCount , nameof ( col ) ) ;
132
- return GetMetadataTypeOrNullCore ( kind , col ) ;
133
- }
134
-
135
- protected abstract ColumnType GetMetadataTypeOrNullCore ( string kind , int col ) ;
136
-
137
- public void GetMetadata < TValue > ( string kind , int col , ref TValue value )
138
- {
139
- Ectx . CheckParam ( 0 <= col && col < ColumnCount , nameof ( col ) ) ;
140
- GetMetadataCore ( kind , col , ref value ) ;
141
- }
142
-
143
- protected abstract void GetMetadataCore < TValue > ( string kind , int col , ref TValue value ) ;
144
- }
145
-
146
72
public static class SimpleSchemaUtils
147
73
{
148
74
public static Schema Create ( IExceptionContext ectx , params KeyValuePair < string , ColumnType > [ ] columns )
0 commit comments