-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Replace predicate with an IEnumerable<DataViewSchema.Column> for IRowToRowMapper.GetRow and ISchemaBoundRowMapper.GetRow #2796
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8c32f37
replacing the `Func<int, bool> active` predicate with an `IEnumerable…
sfilipi 7da0875
renaming col to columnIndex in all the overrides of IDataView.GetGett…
sfilipi 784ab37
Making sure GetRow is an explicit implementation everywhere.
sfilipi f5b4664
addressing PR review, and changing the GetGetter method signature, to…
sfilipi 40ce785
changing the signature for IsColumnActive to take a DataViewSchema.Co…
sfilipi 5489b19
pr review comments
sfilipi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -776,6 +776,41 @@ public static T[] BuildArray<T>(int length, Func<int, T> func) | |
return result; | ||
} | ||
|
||
/// <summary> | ||
/// Given a predicate, over a range of values defined by a limit calculate | ||
/// first the values for which that predicate was true, and second an inverse | ||
/// map. | ||
/// </summary> | ||
/// <param name="schema">The input schema where the predicate can check if columns are active.</param> | ||
/// <param name="pred">The predicate to test for various value</param> | ||
/// <param name="map">An ascending array of values from 0 inclusive | ||
/// to <paramref name="schema.Count"/> exclusive, holding all values for which | ||
/// <paramref name="pred"/> is true</param> | ||
/// <param name="invMap">Forms an inverse mapping of <paramref name="map"/>, | ||
/// so that <c><paramref name="invMap"/>[<paramref name="map"/>[i]] == i</c>, | ||
/// and for other entries not appearing in <paramref name="map"/>, | ||
/// <c><paramref name="invMap"/>[i] == -1</c></param> | ||
public static void BuildSubsetMaps(DataViewSchema schema, Func<DataViewSchema.Column, bool> pred, out int[] map, out int[] invMap) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Hmmm. Is the goal here to enable more elaborate checking I suppose? Totally fine, just interesting. |
||
{ | ||
Contracts.CheckValue(schema, nameof(schema)); | ||
Contracts.Check(schema.Count > 0, nameof(schema)); | ||
Contracts.CheckValue(pred, nameof(pred)); | ||
// REVIEW: Better names? | ||
List<int> mapList = new List<int>(); | ||
invMap = new int[schema.Count]; | ||
for (int c = 0; c < schema.Count; ++c) | ||
{ | ||
if (!pred(schema[c])) | ||
{ | ||
invMap[c] = -1; | ||
continue; | ||
} | ||
invMap[c] = mapList.Count; | ||
mapList.Add(c); | ||
} | ||
map = mapList.ToArray(); | ||
} | ||
|
||
/// <summary> | ||
/// Given a predicate, over a range of values defined by a limit calculate | ||
/// first the values for which that predicate was true, and second an inverse | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Incidentally this was not necessary or helpful. The point is to merely have a method for the method to sink its teeth into, so the type parameter here was not informative. (If anything it is now more obscure.)
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.
This is not essential -- the method will still work the same even with this change, and there should be no cost to it. Just pointing out that there was no need for it.
In reply to: 263101561 [](ancestors = 263101561)