-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Converted Schema to a class #1167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Converted existing row mappers to use Schema.
src/Microsoft.ML.Api/MapTransform.cs
Outdated
|
||
using System; | ||
using System.IO; | ||
using System.Linq; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this leftover from something? I don't see that LINQ gets used anywhere here. #Resolved
|
||
using System; | ||
using System.IO; | ||
using System.Linq; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar, I guess perhaps you were doing something, then chose to do it a different way? #Resolved
/// <summary> | ||
/// A logical row. Every value of every column is retrievable, and immutable. | ||
/// </summary> | ||
public interface IStandaloneRow : ISchematized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IStandaloneRow [](start = 21, length = 14)
significant change 2 #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
} | ||
|
||
/// <summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
summary [](start = 9, length = 7)
significant change 4
src/Microsoft.ML.Core/Data/Schema.cs
Outdated
#pragma warning disable CS0618 // Type or member is obsolete | ||
/// <summary> | ||
/// Manufacture an instance of <see cref="Schema"/> out of any <see cref="ISchema"/>. | ||
/// </summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indenting #Resolved
namespace Microsoft.ML.Runtime.Data | ||
{ | ||
#pragma warning disable CS0618 // Type or member is obsolete | ||
public sealed class Schema : ISchema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Schema [](start = 24, length = 6)
Are you planning on writing actual documentation for this eventually? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Puts a value of a column <paramref name="col"/> into <paramref name="value"/>. | ||
/// This throws if the type <typeparamref name="TValue"/> differs from this column's type. | ||
/// </summary> | ||
void GetValue<TValue>(int col, ref TValue value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetValue(int col, ref TValue value); [](start = 13, length = 44)
I suppose that it would be a bug for GetGetter<>(col)(ref val
to result in a separate value from GetValue<>(col ref val)
.
This strongly suggests that it would be better done via an extension method, rather than an implicit interface method. Otherwise we're just putting a bobby trap into our code.
Not sure which direction we want the extension method to go -- seems like GetValue
as an extension might be cleaner, but I don't insist on this. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If separate implementations are somehow useful, might be useful to know why.
In reply to: 224531809 [](ancestors = 224531809)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think GetValue
is the one I'd prefer to keep. GetGetter
is useful for 'recombining' rows into other rows, but it doesn't add to the consumption layer.
In reply to: 224532997 [](ancestors = 224532997,224531809)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I will for now remove the entire interface :) MetadataRow
is the only implementation.
In reply to: 224543998 [](ancestors = 224543998,224532997,224531809)
I'm done looking :D #Closed |
…earning into feature/new-schema-clean
Time to look again! or approve! It's Hacktober after all In reply to: 429057358 [](ancestors = 429057358) |
src/Microsoft.ML.Core/Data/Schema.cs
Outdated
/// <summary> | ||
/// The metadata of one <see cref="Column"/>. | ||
/// </summary> | ||
public sealed class MetadataRow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MetadataRow [](start = 28, length = 11)
You removed the interface, which is fine. But do you still want it to be ISchematized
? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the name "MetadataRow"... it is row-y in the sense that it is a collection of columns, but otherwise it doesn't seem very row-y somehow.
In reply to: 224834244 [](ancestors = 224834244)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good forward step, thanks @Zruty0.
src/Microsoft.ML.Core/Data/Schema.cs
Outdated
/// <summary> | ||
/// Get the value of the metadata, by column index. | ||
/// </summary> | ||
public void GetValue<TValue>(int col, ref TValue value) => GetGetter<TValue>(col)(ref value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetGetter(col) [](start = 71, length = 22)
Would this throw if TValue is wrong? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// <summary> | ||
/// Get a getter delegate for one value of the metadata row. | ||
/// </summary> | ||
public ValueGetter<TValue> GetGetter<TValue>(int col) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetGetter [](start = 39, length = 9)
Does this method (and the next one) have to be public? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// </summary> | ||
public Metadata Metadata { get; } | ||
|
||
public Column(string name, ColumnType type, Metadata metadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
metadata [](start = 65, length = 8)
any reason why you don't want to have default nullable here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about it. For now, let's keep it as is and observe some more usage patterns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a Schema class for eager schema.
Converted existing row mappers to use Schema.
Fixes #764