Skip to content

Don't create parallel cursor if we have only one element in dataview #197

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Microsoft.ML.Api/DataViewConstructionUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public override bool CanShuffle

public override long? GetRowCount(bool lazy = true)
{
return null;
return (_data as ICollection<TRow>)?.Count;
}

public override IRowCursor GetRowCursor(Func<int, bool> predicate, IRandom rand = null)
Expand Down
18 changes: 9 additions & 9 deletions src/Microsoft.ML.Data/Scorers/RowToRowScorerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public override IRowCursor[] GetRowCursorSet(out IRowCursorConsolidator consolid
var inputs = Source.GetRowCursorSet(out consolidator, predicateInput, n, rand);
Contracts.AssertNonEmpty(inputs);

if (inputs.Length == 1 && n > 1 && WantParallelCursors(predicate))
if (inputs.Length == 1 && n > 1 && WantParallelCursors(predicate) && (Source.GetRowCount() ?? int.MaxValue) > n)
inputs = DataViewUtils.CreateSplitCursors(out consolidator, Host, inputs[0], n);
Contracts.AssertNonEmpty(inputs);

Expand Down Expand Up @@ -432,14 +432,14 @@ protected override void GetMetadataCore<TValue>(string kind, int iinfo, ref TVal
Contracts.Assert(0 <= iinfo && iinfo < InfoCount);
switch (kind)
{
case MetadataUtils.Kinds.ScoreColumnSetId:
_getScoreColumnSetId.Marshal(iinfo, ref value);
break;
default:
if (iinfo < DerivedColumnCount)
throw MetadataUtils.ExceptGetMetadata();
Mapper.OutputSchema.GetMetadata<TValue>(kind, iinfo - DerivedColumnCount, ref value);
break;
case MetadataUtils.Kinds.ScoreColumnSetId:
_getScoreColumnSetId.Marshal(iinfo, ref value);
break;
default:
if (iinfo < DerivedColumnCount)
throw MetadataUtils.ExceptGetMetadata();
Mapper.OutputSchema.GetMetadata<TValue>(kind, iinfo - DerivedColumnCount, ref value);
break;
}
}

Expand Down