Skip to content

Commit 8a45f37

Browse files
authored
Remove lazy parameters for GetRowCount (#1621)
* Remove lazy parameters for GetRowCount * Address comments
1 parent 057c4b9 commit 8a45f37

37 files changed

+69
-76
lines changed

src/Microsoft.ML.Api/DataViewConstructionUtils.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ protected DataViewBase(IHostEnvironment env, string name, InternalSchemaDefiniti
397397
}
398398
}
399399

400-
public abstract long? GetRowCount(bool lazy = true);
400+
public abstract long? GetRowCount();
401401

402402
public abstract IRowCursor GetRowCursor(Func<int, bool> predicate, IRandom rand = null);
403403

@@ -555,7 +555,7 @@ public override bool CanShuffle
555555
get { return true; }
556556
}
557557

558-
public override long? GetRowCount(bool lazy = true)
558+
public override long? GetRowCount()
559559
{
560560
return _data.Count;
561561
}
@@ -654,7 +654,7 @@ public override bool CanShuffle
654654
get { return false; }
655655
}
656656

657-
public override long? GetRowCount(bool lazy = true)
657+
public override long? GetRowCount()
658658
{
659659
return (_data as ICollection<TRow>)?.Count;
660660
}
@@ -735,7 +735,7 @@ public override bool CanShuffle
735735
get { return false; }
736736
}
737737

738-
public override long? GetRowCount(bool lazy = true)
738+
public override long? GetRowCount()
739739
{
740740
return null;
741741
}

src/Microsoft.ML.Api/StatefulFilterTransform.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private StatefulFilterTransform(IHostEnvironment env, StatefulFilterTransform<TS
9999

100100
public Schema Schema => _bindings.Schema;
101101

102-
public long? GetRowCount(bool lazy = true)
102+
public long? GetRowCount()
103103
{
104104
// REVIEW: currently stateful map is implemented via filter, and this is sub-optimal.
105105
return null;

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,15 @@ public interface IDataView : ISchematized
8282
bool CanShuffle { get; }
8383

8484
/// <summary>
85-
/// Returns the number of rows if known. Null means unknown. If lazy is true, then
86-
/// this is permitted to return null when it might return a non-null value on a subsequent
87-
/// call. This indicates, that the transform does not YET know the number of rows, but
88-
/// may in the future. If lazy is false, then this is permitted to do some work (no more
89-
/// that it would normally do for cursoring) to determine the number of rows.
85+
/// Returns the number of rows if known. Returning null means that the row count is unknown but
86+
/// it might return a non-null value on a subsequent call. This indicates, that the transform does
87+
/// not YET know the number of rows, but may in the future. Its implementation's computation
88+
/// complexity should be O(1).
9089
///
91-
/// Most components will return the same answer whether lazy is true or false. Some, like
92-
/// a cache, might return null until the cache is fully populated (when lazy is true). When
93-
/// lazy is false, such a cache would block until the cache was populated.
90+
/// Most implementation will return the same answer every time. Some, like a cache, might
91+
/// return null until the cache is fully populated.
9492
/// </summary>
95-
long? GetRowCount(bool lazy = true);
93+
long? GetRowCount();
9694

9795
/// <summary>
9896
/// Get a row cursor. The active column indices are those for which needCol(col) returns true.

src/Microsoft.ML.Data/Data/DataViewUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static string[] GetTempColumnNames(this ISchema schema, int n, string tag
7777
/// </summary>
7878
public static long ComputeRowCount(IDataView view)
7979
{
80-
long? countNullable = view.GetRowCount(lazy: false);
80+
long? countNullable = view.GetRowCount();
8181
if (countNullable != null)
8282
return countNullable.Value;
8383
long count = 0;

src/Microsoft.ML.Data/Data/RowCursorUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ public IRowCursor[] GetRowCursorSet(out IRowCursorConsolidator consolidator, Fun
541541
return new IRowCursor[] { GetRowCursor(needCol, rand) };
542542
}
543543

544-
public long? GetRowCount(bool lazy = true)
544+
public long? GetRowCount()
545545
{
546546
return 1;
547547
}

src/Microsoft.ML.Data/DataLoadSave/Binary/BinaryLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ public void GetMetadata<TValue>(string kind, int col, ref TValue value)
761761

762762
private long RowCount { get { return _header.RowCount; } }
763763

764-
public long? GetRowCount(bool lazy = true) { return RowCount; }
764+
public long? GetRowCount() { return RowCount; }
765765

766766
public bool CanShuffle { get { return true; } }
767767

src/Microsoft.ML.Data/DataLoadSave/CompositeDataLoader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,9 @@ private static string GenerateTag(int index)
557557
return string.Format("xf{0:00}", index);
558558
}
559559

560-
public long? GetRowCount(bool lazy = true)
560+
public long? GetRowCount()
561561
{
562-
return View.GetRowCount(lazy);
562+
return View.GetRowCount();
563563
}
564564

565565
public bool CanShuffle => View.CanShuffle;

src/Microsoft.ML.Data/DataLoadSave/PartitionedFileLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public void Save(ModelSaveContext ctx)
287287

288288
public Schema Schema { get; }
289289

290-
public long? GetRowCount(bool lazy = true)
290+
public long? GetRowCount()
291291
{
292292
return null;
293293
}

src/Microsoft.ML.Data/DataLoadSave/Text/TextLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ public BoundLoader(TextLoader reader, IMultiStreamSource files)
13521352
_files = files;
13531353
}
13541354

1355-
public long? GetRowCount(bool lazy = true)
1355+
public long? GetRowCount()
13561356
{
13571357
// We don't know how many rows there are.
13581358
// REVIEW: Should we try to support RowCount?

src/Microsoft.ML.Data/DataLoadSave/Text/TextSaver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ private void WriteDataCore(IChannel ch, TextWriter writer, IDataView data,
420420
if (_outputSchema)
421421
WriteSchemaAsComment(writer, header);
422422

423-
double rowCount = data.GetRowCount(true) ?? double.NaN;
423+
double rowCount = data.GetRowCount() ?? double.NaN;
424424
using (var pch = !_silent ? _host.StartProgressChannel("TextSaver: saving data") : null)
425425
{
426426
long stateCount = 0;

0 commit comments

Comments
 (0)