Skip to content

Commit 383c26f

Browse files
committed
Tom's comments.
1 parent e672ece commit 383c26f

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed

src/Microsoft.ML.Core/Data/IRowToRowMapper.cs

+6-9
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@ namespace Microsoft.ML.Data
1616
/// so to rebind, the same input column names must be used.
1717
/// Implementations of this interface are typically created over defined input <see cref="DataViewSchema"/>.
1818
/// </summary>
19-
public interface IRowToRowMapper : IRowToRowMapperBase
20-
{
21-
/// <summary>
22-
/// Given a set of columns, return the input columns that are needed to generate those output columns.
23-
/// </summary>
24-
IEnumerable<DataViewSchema.Column> GetDependencies(IEnumerable<DataViewSchema.Column> dependingColumns);
25-
}
26-
27-
public interface IRowToRowMapperBase
19+
public interface IRowToRowMapper
2820
{
2921
/// <summary>
3022
/// Mappers are defined as accepting inputs with this very specific schema.
@@ -36,6 +28,11 @@ public interface IRowToRowMapperBase
3628
/// </summary>
3729
DataViewSchema OutputSchema { get; }
3830

31+
/// <summary>
32+
/// Given a set of columns, return the input columns that are needed to generate those output columns.
33+
/// </summary>
34+
IEnumerable<DataViewSchema.Column> GetDependencies(IEnumerable<DataViewSchema.Column> dependingColumns);
35+
3936
/// <summary>
4037
/// Get an <see cref="DataViewRow"/> with the indicated active columns, based on the input <paramref name="input"/>.
4138
/// The active columns are those for which <paramref name="active"/> returns true. Getting values on inactive

src/Microsoft.ML.Core/Data/ISchemaBindableMapper.cs

+23-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
56
using System.Collections.Generic;
67
using Microsoft.Data.DataView;
78

@@ -18,7 +19,7 @@ namespace Microsoft.ML.Data
1819
/// features column. New predictors can implement <see cref="ISchemaBindableMapper"/> directly. Implementing <see cref="ISchemaBindableMapper"/>
1920
/// includes implementing a corresponding <see cref="ISchemaBoundMapper"/> (or <see cref="ISchemaBoundRowMapper"/>) and a corresponding ISchema
2021
/// for the output schema of the <see cref="ISchemaBoundMapper"/>. In case the <see cref="ISchemaBoundRowMapper"/> interface is implemented,
21-
/// the SimpleRow class can be used in the <see cref="IRowToRowMapperBase.GetRow"/> method.
22+
/// the SimpleRow class can be used in the <see cref="IRowToRowMapper.GetRow"/> method.
2223
/// </summary>
2324
[BestFriend]
2425
internal interface ISchemaBindableMapper
@@ -55,20 +56,36 @@ internal interface ISchemaBoundMapper
5556
}
5657

5758
/// <summary>
58-
/// This interface combines <see cref="ISchemaBoundMapper"/> with <see cref="IRowToRowMapper"/>.
59+
/// This interface extends <see cref="ISchemaBoundMapper"/>.
5960
/// </summary>
6061
[BestFriend]
61-
internal interface ISchemaBoundRowMapper : ISchemaBoundMapper, IRowToRowMapperBase
62+
internal interface ISchemaBoundRowMapper : ISchemaBoundMapper
6263
{
6364
/// <summary>
64-
/// There are two schemas from <see cref="ISchemaBoundMapper"/> and <see cref="IRowToRowMapper"/>.
65-
/// Since the two parent schema's are identical in all derived classes, we merge them into <see cref="OutputSchema"/>.
65+
/// Input schema accepted.
6666
/// </summary>
67-
new DataViewSchema OutputSchema { get; }
67+
DataViewSchema InputSchema { get; }
6868

6969
/// <summary>
7070
/// Given a set of columns, from the newly generated ones, return the input columns that are needed to generate those output columns.
7171
/// </summary>
7272
IEnumerable<DataViewSchema.Column> GetDependenciesForNewColumns(IEnumerable<DataViewSchema.Column> dependingColumns);
73+
74+
/// <summary>
75+
/// Get an <see cref="DataViewRow"/> with the indicated active columns, based on the input <paramref name="input"/>.
76+
/// The active columns are those for which <paramref name="active"/> returns true. Getting values on inactive
77+
/// columns of the returned row will throw. Null predicates are disallowed.
78+
///
79+
/// The <see cref="DataViewRow.Schema"/> of <paramref name="input"/> should be the same object as
80+
/// <see cref="InputSchema"/>. Implementors of this method should throw if that is not the case. Conversely,
81+
/// the returned value must have the same schema as <see cref="ISchemaBoundMapper.OutputSchema"/>.
82+
///
83+
/// This method creates a live connection between the input <see cref="DataViewRow"/> and the output <see
84+
/// cref="DataViewRow"/>. In particular, when the getters of the output <see cref="DataViewRow"/> are invoked, they invoke the
85+
/// getters of the input row and base the output values on the current values of the input <see cref="DataViewRow"/>.
86+
/// The output <see cref="DataViewRow"/> values are re-computed when requested through the getters. Also, the returned
87+
/// <see cref="DataViewRow"/> will dispose <paramref name="input"/> when it is disposed.
88+
/// </summary>
89+
DataViewRow GetRow(DataViewRow input, Func<int, bool> active);
7390
}
7491
}

src/Microsoft.ML.Data/Transforms/NopTransform.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal sealed class NopTransform : IDataTransform, IRowToRowMapper
2727

2828
public IDataView Source { get; }
2929

30-
DataViewSchema IRowToRowMapperBase.InputSchema => Source.Schema;
30+
DataViewSchema IRowToRowMapper.InputSchema => Source.Schema;
3131

3232
/// <summary>
3333
/// Creates a NopTransform if the input is not an IDataTransform.

src/Microsoft.ML.TimeSeries/SequentialTransformerBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ void ISaveAsPfa.SaveAsPfa(BoundPfaContext ctx)
784784
return GetActive(predicate);
785785
}
786786

787-
DataViewSchema IRowToRowMapperBase.InputSchema => Source.Schema;
787+
DataViewSchema IRowToRowMapper.InputSchema => Source.Schema;
788788

789789
public DataViewRow GetRow(DataViewRow input, Func<int, bool> active)
790790
{

0 commit comments

Comments
 (0)