@@ -320,7 +320,7 @@ protected override void VerifyView(IDataView view)
320
320
private readonly IMultiStreamSource _file ;
321
321
private readonly IHost _host ;
322
322
private readonly Header _header ;
323
- private readonly SchemaImpl _schema ;
323
+ private readonly TransposeSlotTypeHolder _transposeSlotTypeHolder ;
324
324
325
325
// This is a sub-IDV holding the schema, and optionally the data stored in row-wise format.
326
326
private readonly SubIdvEntry . SchemaSubIdv _schemaEntry ;
@@ -364,9 +364,9 @@ private static VersionInfo GetVersionInfo()
364
364
// inspect the schema. We also want to ensure that the useful property that
365
365
// a cursor and view's schemas are the same, is preserved, which allows us
366
366
// to use the cursors from the schema view if convenient to do so.
367
- public Schema Schema { get { return _schemaEntry . GetView ( ) . Schema ; } }
367
+ public Schema Schema => _schemaEntry . GetView ( ) . Schema ;
368
368
369
- ITransposeSchema ITransposeDataView . TransposeSchema { get { return _schema ; } }
369
+ ITransposeSlotTypeHolder ITransposeDataView . TransposeSlotTypeHolder => _transposeSlotTypeHolder ;
370
370
371
371
/// <summary>
372
372
/// Whether the master schema sub-IDV has the actual data.
@@ -411,7 +411,7 @@ public TransposeLoader(IHostEnvironment env, Arguments args, IMultiStreamSource
411
411
_entries = new SubIdvEntry . TransposedSubIdv [ _header . ColumnCount ] ;
412
412
for ( int c = 0 ; c < _entries . Length ; ++ c )
413
413
_entries [ c ] = new SubIdvEntry . TransposedSubIdv ( this , reader , c ) ;
414
- _schema = new SchemaImpl ( this ) ;
414
+ _transposeSlotTypeHolder = new TransposeSlotTypeHolder ( this ) ;
415
415
if ( ! HasRowData )
416
416
{
417
417
_colTransposers = new Transposer [ _header . ColumnCount ] ;
@@ -445,7 +445,7 @@ private TransposeLoader(IHost host, ModelLoadContext ctx, IMultiStreamSource fil
445
445
_entries = new SubIdvEntry . TransposedSubIdv [ _header . ColumnCount ] ;
446
446
for ( int c = 0 ; c < _entries . Length ; ++ c )
447
447
_entries [ c ] = new SubIdvEntry . TransposedSubIdv ( this , reader , c ) ;
448
- _schema = new SchemaImpl ( this ) ;
448
+ _transposeSlotTypeHolder = new TransposeSlotTypeHolder ( this ) ;
449
449
if ( ! HasRowData )
450
450
{
451
451
_colTransposers = new Transposer [ _header . ColumnCount ] ;
@@ -608,50 +608,20 @@ private unsafe Header InitHeader(BinaryReader reader)
608
608
return header ;
609
609
}
610
610
611
- private sealed class SchemaImpl : ITransposeSchema
611
+ private sealed class TransposeSlotTypeHolder : ITransposeSlotTypeHolder
612
612
{
613
613
private readonly TransposeLoader _parent ;
614
614
private Schema Schema { get { return _parent . Schema ; } }
615
615
private IHost Host { get { return _parent . _host ; } }
616
616
public int ColumnCount { get { return Schema . Count ; } }
617
617
618
- public SchemaImpl ( TransposeLoader parent )
618
+ public TransposeSlotTypeHolder ( TransposeLoader parent )
619
619
{
620
620
Contracts . AssertValue ( parent ) ;
621
621
_parent = parent ;
622
622
var view = parent . _schemaEntry . GetView ( ) . Schema ;
623
623
}
624
624
625
- public string GetColumnName ( int col )
626
- {
627
- return Schema [ col ] . Name ;
628
- }
629
-
630
- public bool TryGetColumnIndex ( string name , out int col )
631
- {
632
- return Schema . TryGetColumnIndex ( name , out col ) ;
633
- }
634
-
635
- public ColumnType GetColumnType ( int col )
636
- {
637
- return Schema [ col ] . Type ;
638
- }
639
-
640
- public ColumnType GetMetadataTypeOrNull ( string kind , int col )
641
- {
642
- return Schema [ col ] . Metadata . Schema . GetColumnOrNull ( kind ) ? . Type ;
643
- }
644
-
645
- public IEnumerable < KeyValuePair < string , ColumnType > > GetMetadataTypes ( int col )
646
- {
647
- return Schema [ col ] . Metadata . Schema . Select ( c => new KeyValuePair < string , ColumnType > ( c . Name , c . Type ) ) ;
648
- }
649
-
650
- public void GetMetadata < TValue > ( string kind , int col , ref TValue value )
651
- {
652
- Schema [ col ] . Metadata . GetValue ( kind , ref value ) ;
653
- }
654
-
655
625
public VectorType GetSlotType ( int col )
656
626
{
657
627
Host . CheckParam ( 0 <= col && col < ColumnCount , nameof ( col ) ) ;
@@ -696,7 +666,7 @@ public SlotCursor GetSlotCursor(int col)
696
666
_host . CheckParam ( 0 <= col && col < _header . ColumnCount , nameof ( col ) ) ;
697
667
// We don't want the type error, if there is one, to be handled by the get-getter, because
698
668
// at the point we've gotten the interior cursor, but not yet constructed the slot cursor.
699
- ColumnType cursorType = _schema . GetSlotType ( col ) . ItemType ;
669
+ ColumnType cursorType = _transposeSlotTypeHolder . GetSlotType ( col ) . ItemType ;
700
670
RowCursor inputCursor = view . GetRowCursor ( c => true ) ;
701
671
try
702
672
{
@@ -781,8 +751,8 @@ private Transposer EnsureAndGetTransposer(int col)
781
751
_host . AssertValue ( view ) ;
782
752
_host . Assert ( view . Schema . Count == 1 ) ;
783
753
var trans = _colTransposers [ col ] = Transposer . Create ( _host , view , false , new int [ ] { 0 } ) ;
784
- _host . Assert ( ( ( ITransposeDataView ) trans ) . TransposeSchema . ColumnCount == 1 ) ;
785
- _host . Assert ( ( ( ITransposeDataView ) trans ) . TransposeSchema . GetSlotType ( 0 ) . ValueCount == Schema [ col ] . Type . ValueCount ) ;
754
+ _host . Assert ( trans . Schema . Count == 1 ) ;
755
+ _host . Assert ( trans . TransposeSlotTypeHolder . GetSlotType ( 0 ) . ValueCount == Schema [ col ] . Type . ValueCount ) ;
786
756
}
787
757
}
788
758
}
@@ -843,7 +813,7 @@ private void Init(int col)
843
813
Ch . Assert ( 0 <= col && col < Schema . Count ) ;
844
814
Ch . Assert ( _colToActivesIndex [ col ] >= 0 ) ;
845
815
var type = Schema [ col ] . Type ;
846
- Ch . Assert ( ( ( ITransposeDataView ) _parent ) . TransposeSchema . GetSlotType ( col ) . ValueCount == _parent . _header . RowCount ) ;
816
+ Ch . Assert ( ( ( ITransposeDataView ) _parent ) . TransposeSlotTypeHolder . GetSlotType ( col ) . ValueCount == _parent . _header . RowCount ) ;
847
817
Action < int > func = InitOne < int > ;
848
818
if ( type . IsVector )
849
819
func = InitVec < int > ;
0 commit comments