@@ -27,11 +27,6 @@ public sealed class Schema : ISchema, IReadOnlyList<Schema.Column>
27
27
private readonly Column [ ] _columns ;
28
28
private readonly Dictionary < string , int > _nameMap ;
29
29
30
- /// <summary>
31
- /// Number of columns in the schema.
32
- /// </summary>
33
- public int ColumnCount => _columns . Length ;
34
-
35
30
/// <summary>
36
31
/// Number of columns in the schema.
37
32
/// </summary>
@@ -249,7 +244,7 @@ public void GetValue<TValue>(string kind, ref TValue value)
249
244
GetGetter < TValue > ( column . Value . Index ) ( ref value ) ;
250
245
}
251
246
252
- public override string ToString ( ) => string . Join ( ", " , Schema . GetColumns ( ) . Select ( x => x . column . Name ) ) ;
247
+ public override string ToString ( ) => string . Join ( ", " , Schema . Select ( x => x . Name ) ) ;
253
248
254
249
}
255
250
@@ -270,11 +265,6 @@ internal Schema(Column[] columns)
270
265
}
271
266
}
272
267
273
- /// <summary>
274
- /// Get all non-hidden columns as pairs of (index, <see cref="Column"/>).
275
- /// </summary>
276
- public IEnumerable < ( int index , Column column ) > GetColumns ( ) => _nameMap . Values . Select ( idx => ( idx , _columns [ idx ] ) ) ;
277
-
278
268
/// <summary>
279
269
/// Manufacture an instance of <see cref="Schema"/> out of any <see cref="ISchema"/>.
280
270
/// </summary>
@@ -310,38 +300,37 @@ private static Delegate GetMetadataGetterDelegate<TValue>(ISchema schema, int co
310
300
return getter ;
311
301
}
312
302
303
+ /// <summary>
304
+ /// Legacy method to get the column index.
305
+ /// DO NOT USE: use <see cref="GetColumnOrNull"/> instead.
306
+ /// </summary>
307
+ [ BestFriend ]
308
+ internal bool TryGetColumnIndex ( string name , out int col )
309
+ {
310
+ col = GetColumnOrNull ( name ) ? . Index ?? - 1 ;
311
+ return col >= 0 ;
312
+ }
313
+
313
314
#region Legacy schema API to be removed
314
- public string GetColumnName ( int col ) => this [ col ] . Name ;
315
+ /// <summary>
316
+ /// Number of columns in the schema.
317
+ /// </summary>
318
+ int ISchema . ColumnCount => _columns . Length ;
315
319
316
- public ColumnType GetColumnType ( int col ) => this [ col ] . Type ;
320
+ string ISchema . GetColumnName ( int col ) => this [ col ] . Name ;
317
321
318
- public IEnumerable < KeyValuePair < string , ColumnType > > GetMetadataTypes ( int col )
319
- {
320
- var meta = this [ col ] . Metadata ;
321
- if ( meta == null )
322
- return Enumerable . Empty < KeyValuePair < string , ColumnType > > ( ) ;
323
- return meta . Schema . GetColumns ( ) . Select ( c => new KeyValuePair < string , ColumnType > ( c . column . Name , c . column . Type ) ) ;
324
- }
322
+ ColumnType ISchema . GetColumnType ( int col ) => this [ col ] . Type ;
325
323
326
- public ColumnType GetMetadataTypeOrNull ( string kind , int col )
327
- {
328
- var meta = this [ col ] . Metadata ;
329
- if ( meta == null )
330
- return null ;
331
- if ( meta . Schema . TryGetColumnIndex ( kind , out int metaCol ) )
332
- return meta . Schema [ metaCol ] . Type ;
333
- return null ;
334
- }
324
+ IEnumerable < KeyValuePair < string , ColumnType > > ISchema . GetMetadataTypes ( int col )
325
+ => this [ col ] . Metadata . Schema . Select ( c => new KeyValuePair < string , ColumnType > ( c . Name , c . Type ) ) ;
335
326
336
- public void GetMetadata < TValue > ( string kind , int col , ref TValue value )
337
- {
338
- var meta = this [ col ] . Metadata ;
339
- if ( meta == null )
340
- throw MetadataUtils . ExceptGetMetadata ( ) ;
341
- meta . GetValue ( kind , ref value ) ;
342
- }
327
+ ColumnType ISchema . GetMetadataTypeOrNull ( string kind , int col )
328
+ => this [ col ] . Metadata . Schema . GetColumnOrNull ( kind ) ? . Type ;
329
+
330
+ void ISchema . GetMetadata < TValue > ( string kind , int col , ref TValue value )
331
+ => this [ col ] . Metadata . GetValue ( kind , ref value ) ;
343
332
344
- public bool TryGetColumnIndex ( string name , out int col )
333
+ bool ISchema . TryGetColumnIndex ( string name , out int col )
345
334
{
346
335
col = GetColumnOrNull ( name ) ? . Index ?? - 1 ;
347
336
return col >= 0 ;
0 commit comments