@@ -173,14 +173,14 @@ public static DataViewRowCursor[] CreateSplitCursors(IChannelProvider provider,
173
173
/// Return whether all the active columns, as determined by the predicate, are
174
174
/// cachable - either primitive types or vector types.
175
175
/// </summary>
176
- public static bool AllCacheable ( DataViewSchema schema , Func < int , bool > predicate )
176
+ public static bool AllCacheable ( DataViewSchema schema , Func < DataViewSchema . Column , bool > predicate )
177
177
{
178
178
Contracts . CheckValue ( schema , nameof ( schema ) ) ;
179
179
Contracts . CheckValue ( predicate , nameof ( predicate ) ) ;
180
180
181
181
for ( int col = 0 ; col < schema . Count ; col ++ )
182
182
{
183
- if ( ! predicate ( col ) )
183
+ if ( ! predicate ( schema [ col ] ) )
184
184
continue ;
185
185
var type = schema [ col ] . Type ;
186
186
if ( ! IsCacheable ( type ) )
@@ -239,10 +239,10 @@ public static bool SameSchemaAndActivity(DataViewRowCursor[] cursors)
239
239
// All cursors must have the same columns active.
240
240
for ( int c = 0 ; c < schema . Count ; ++ c )
241
241
{
242
- bool active = firstCursor . IsColumnActive ( c ) ;
242
+ bool active = firstCursor . IsColumnActive ( schema [ c ] ) ;
243
243
for ( int i = 1 ; i < cursors . Length ; ++ i )
244
244
{
245
- if ( cursors [ i ] . IsColumnActive ( c ) != active )
245
+ if ( cursors [ i ] . IsColumnActive ( schema [ c ] ) != active )
246
246
return false ;
247
247
}
248
248
}
@@ -334,7 +334,7 @@ private static DataViewRowCursor ConsolidateCore(IChannelProvider provider, Data
334
334
335
335
int [ ] activeToCol ;
336
336
int [ ] colToActive ;
337
- Utils . BuildSubsetMaps ( schema . Count , cursor . IsColumnActive , out activeToCol , out colToActive ) ;
337
+ Utils . BuildSubsetMaps ( schema . Count , schema , cursor . IsColumnActive , out activeToCol , out colToActive ) ;
338
338
339
339
// Because the schema of the consolidator is not necessary fixed, we are merely
340
340
// opportunistic about buffer sharing, from cursoring to cursoring. If we can do
@@ -517,7 +517,7 @@ private DataViewRowCursor[] SplitCore(IChannelProvider ch, DataViewRowCursor inp
517
517
// Create the mappings between active column index, and column index.
518
518
int [ ] activeToCol ;
519
519
int [ ] colToActive ;
520
- Utils . BuildSubsetMaps ( _schema . Count , input . IsColumnActive , out activeToCol , out colToActive ) ;
520
+ Utils . BuildSubsetMaps ( _schema . Count , _schema , input . IsColumnActive , out activeToCol , out colToActive ) ;
521
521
522
522
Func < DataViewRowCursor , int , InPipe > createFunc = CreateInPipe < int > ;
523
523
var inGenMethod = createFunc . GetMethodInfo ( ) . GetGenericMethodDefinition ( ) ;
@@ -534,14 +534,14 @@ private DataViewRowCursor[] SplitCore(IChannelProvider ch, DataViewRowCursor inp
534
534
{
535
535
ch . Assert ( 0 <= activeToCol [ c ] && activeToCol [ c ] < _schema . Count ) ;
536
536
ch . Assert ( c == 0 || activeToCol [ c - 1 ] < activeToCol [ c ] ) ;
537
- ch . Assert ( input . IsColumnActive ( activeToCol [ c ] ) ) ;
538
- var type = input . Schema [ activeToCol [ c ] ] . Type ;
539
- ch . Assert ( type . IsCacheable ( ) ) ;
537
+ var column = input . Schema [ activeToCol [ c ] ] ;
538
+ ch . Assert ( input . IsColumnActive ( column ) ) ;
539
+ ch . Assert ( column . Type . IsCacheable ( ) ) ;
540
540
arguments [ 1 ] = activeToCol [ c ] ;
541
541
var inPipe = inPipes [ c ] =
542
- ( InPipe ) inGenMethod . MakeGenericMethod ( type . RawType ) . Invoke ( this , arguments ) ;
542
+ ( InPipe ) inGenMethod . MakeGenericMethod ( column . Type . RawType ) . Invoke ( this , arguments ) ;
543
543
for ( int i = 0 ; i < cthd ; ++ i )
544
- outPipes [ i ] [ c ] = inPipe . CreateOutPipe ( type ) ;
544
+ outPipes [ i ] [ c ] = inPipe . CreateOutPipe ( column . Type ) ;
545
545
}
546
546
// Beyond the InPipes corresponding to column values, we have extra side info pipes.
547
547
int idIdx = activeToCol . Length + ( int ) ExtraIndex . Id ;
@@ -1105,10 +1105,10 @@ protected override bool MoveNextCore()
1105
1105
/// <summary>
1106
1106
/// Returns whether the given column is active in this row.
1107
1107
/// </summary>
1108
- public override bool IsColumnActive ( int columnIndex )
1108
+ public override bool IsColumnActive ( DataViewSchema . Column column )
1109
1109
{
1110
- Ch . CheckParam ( 0 <= columnIndex && columnIndex < _colToActive . Length , nameof ( columnIndex ) ) ;
1111
- return _colToActive [ columnIndex ] >= 0 ;
1110
+ Ch . CheckParam ( column . Index < _colToActive . Length , nameof ( column ) ) ;
1111
+ return _colToActive [ column . Index ] >= 0 ;
1112
1112
}
1113
1113
1114
1114
/// <summary>
@@ -1120,7 +1120,7 @@ public override bool IsColumnActive(int columnIndex)
1120
1120
/// <param name="column"> is the output column whose getter should be returned.</param>
1121
1121
public override ValueGetter < TValue > GetGetter < TValue > ( DataViewSchema . Column column )
1122
1122
{
1123
- Ch . CheckParam ( IsColumnActive ( column . Index ) , nameof ( column ) , "requested column not active." ) ;
1123
+ Ch . CheckParam ( IsColumnActive ( column ) , nameof ( column ) , "requested column not active." ) ;
1124
1124
Ch . CheckParam ( column . Index < _colToActive . Length , nameof ( column ) , "requested column is not active or valid for the Schema." ) ;
1125
1125
1126
1126
var getter = _getters [ _colToActive [ column . Index ] ] as ValueGetter < TValue > ;
@@ -1180,7 +1180,7 @@ public SynchronousConsolidatingCursor(IChannelProvider provider, DataViewRowCurs
1180
1180
_cursors = cursors ;
1181
1181
_schema = _cursors [ 0 ] . Schema ;
1182
1182
1183
- Utils . BuildSubsetMaps ( _schema . Count , _cursors [ 0 ] . IsColumnActive , out _activeToCol , out _colToActive ) ;
1183
+ Utils . BuildSubsetMaps ( _schema . Count , _schema , _cursors [ 0 ] . IsColumnActive , out _activeToCol , out _colToActive ) ;
1184
1184
1185
1185
Func < int , Delegate > func = CreateGetter < int > ;
1186
1186
_methInfo = func . GetMethodInfo ( ) . GetGenericMethodDefinition ( ) ;
@@ -1251,7 +1251,7 @@ private Delegate CreateGetter<T>(int col)
1251
1251
var cursor = _cursors [ i ] ;
1252
1252
Ch . AssertValue ( cursor ) ;
1253
1253
Ch . Assert ( col < cursor . Schema . Count ) ;
1254
- Ch . Assert ( cursor . IsColumnActive ( col ) ) ;
1254
+ Ch . Assert ( cursor . IsColumnActive ( Schema [ col ] ) ) ;
1255
1255
Ch . Assert ( type . Equals ( cursor . Schema [ col ] . Type ) ) ;
1256
1256
getters [ i ] = _cursors [ i ] . GetGetter < T > ( cursor . Schema [ col ] ) ;
1257
1257
}
@@ -1296,10 +1296,10 @@ protected override bool MoveNextCore()
1296
1296
/// <summary>
1297
1297
/// Returns whether the given column is active in this row.
1298
1298
/// </summary>
1299
- public override bool IsColumnActive ( int columnIndex )
1299
+ public override bool IsColumnActive ( DataViewSchema . Column column )
1300
1300
{
1301
- Ch . CheckParam ( 0 <= columnIndex && columnIndex < _colToActive . Length , nameof ( columnIndex ) ) ;
1302
- return _colToActive [ columnIndex ] >= 0 ;
1301
+ Ch . CheckParam ( column . Index < _colToActive . Length , nameof ( column ) ) ;
1302
+ return _colToActive [ column . Index ] >= 0 ;
1303
1303
}
1304
1304
1305
1305
/// <summary>
@@ -1311,7 +1311,7 @@ public override bool IsColumnActive(int columnIndex)
1311
1311
/// <param name="column"> is the output column whose getter should be returned.</param>
1312
1312
public override ValueGetter < TValue > GetGetter < TValue > ( DataViewSchema . Column column )
1313
1313
{
1314
- Ch . CheckParam ( IsColumnActive ( column . Index ) , nameof ( column ) , "requested column not active" ) ;
1314
+ Ch . CheckParam ( IsColumnActive ( column ) , nameof ( column ) , "requested column not active" ) ;
1315
1315
Ch . CheckParam ( column . Index < _colToActive . Length , nameof ( column ) , "requested column not active or is invalid for the schema. " ) ;
1316
1316
1317
1317
var getter = _getters [ _colToActive [ column . Index ] ] as ValueGetter < TValue > ;
0 commit comments