Skip to content

Conversation

Zruty0
Copy link
Contributor

@Zruty0 Zruty0 commented Oct 5, 2018

Created a Schema class for eager schema.
Converted existing row mappers to use Schema.

Fixes #764

Converted existing row mappers to use Schema.
@Zruty0 Zruty0 added the API Issues pertaining the friendly API label Oct 5, 2018
@Zruty0 Zruty0 self-assigned this Oct 5, 2018
@Zruty0 Zruty0 requested a review from TomFinley October 5, 2018 21:12
@TomFinley TomFinley requested a review from yaeldekel October 5, 2018 21:13

using System;
using System.IO;
using System.Linq;
Copy link
Contributor

@TomFinley TomFinley Oct 5, 2018

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;
Copy link
Contributor

@TomFinley TomFinley Oct 5, 2018

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

@Zruty0
Copy link
Contributor Author

Zruty0 commented Oct 10, 2018

// Licensed to the .NET Foundation under one or more agreements.

significant change 1


Refers to: src/Microsoft.ML.Core/Data/Schema.cs:1 in 95daa3d. [](commit_id = 95daa3d, deletion_comment = False)

/// <summary>
/// A logical row. Every value of every column is retrievable, and immutable.
/// </summary>
public interface IStandaloneRow : ISchematized
Copy link
Contributor Author

@Zruty0 Zruty0 Oct 10, 2018

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually not any more


In reply to: 224181114 [](ancestors = 224181114)

@Zruty0
Copy link
Contributor Author

Zruty0 commented Oct 10, 2018

// Licensed to the .NET Foundation under one or more agreements.

significant change 3


Refers to: src/Microsoft.ML.Data/DataView/RowToRowMapperTransform.cs:1 in 95daa3d. [](commit_id = 95daa3d, deletion_comment = False)

}
}

/// <summary>
Copy link
Contributor Author

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

#pragma warning disable CS0618 // Type or member is obsolete
/// <summary>
/// Manufacture an instance of <see cref="Schema"/> out of any <see cref="ISchema"/>.
/// </summary>
Copy link
Member

@sfilipi sfilipi Oct 11, 2018

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
Copy link
Contributor

@TomFinley TomFinley Oct 11, 2018

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do right now


In reply to: 224531123 [](ancestors = 224531123)

/// 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);
Copy link
Contributor

@TomFinley TomFinley Oct 11, 2018

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

Copy link
Contributor

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)

Copy link
Contributor Author

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)

Copy link
Contributor Author

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)

@TomFinley
Copy link
Contributor

TomFinley commented Oct 11, 2018

I'm done looking :D #Closed

@Zruty0
Copy link
Contributor Author

Zruty0 commented Oct 11, 2018

Time to look again! or approve! It's Hacktober after all


In reply to: 429057358 [](ancestors = 429057358)

/// <summary>
/// The metadata of one <see cref="Column"/>.
/// </summary>
public sealed class MetadataRow
Copy link
Contributor

@TomFinley TomFinley Oct 12, 2018

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

Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to Metadata


In reply to: 224835091 [](ancestors = 224835091,224834244)

Copy link
Contributor

@TomFinley TomFinley left a 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.

/// <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);
Copy link

@yaeldekel yaeldekel Oct 12, 2018

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes


In reply to: 224846502 [](ancestors = 224846502)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should at least


In reply to: 224847616 [](ancestors = 224847616,224846502)

/// <summary>
/// Get a getter delegate for one value of the metadata row.
/// </summary>
public ValueGetter<TValue> GetGetter<TValue>(int col)
Copy link

@yaeldekel yaeldekel Oct 12, 2018

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetGetter does. GetValue by col didn't


In reply to: 224846761 [](ancestors = 224846761)

/// </summary>
public Metadata Metadata { get; }

public Column(string name, ColumnType type, Metadata metadata)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@Zruty0 Zruty0 merged commit 8e77d0f into dotnet:master Oct 16, 2018
@ghost ghost locked as resolved and limited conversation to collaborators Mar 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API Issues pertaining the friendly API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants