Skip to content

Commit c8755a2

Browse files
authored
MLContext.Data.ReadFromBinary to accept IMultiStreamSource rather than Stream (dotnet#2058)
* MLContext.Data.ReadFromBinary to accept IMultiStreamSource rather than Stream * Hiding ctor and some methods in BinaryLoader that accept Stream
1 parent 5359d37 commit c8755a2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Diff for: src/Microsoft.ML.Data/DataLoadSave/Binary/BinaryLoader.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ private BinaryLoader(Arguments args, IHost host, Stream stream, bool leaveOpen)
823823
/// <param name="args">Arguments</param>
824824
/// <param name="env">Host environment</param>
825825
/// <param name="leaveOpen">Whether to leave the input stream open</param>
826-
public BinaryLoader(IHostEnvironment env, Arguments args, Stream stream, bool leaveOpen = true)
826+
internal BinaryLoader(IHostEnvironment env, Arguments args, Stream stream, bool leaveOpen = true)
827827
: this(args, env.Register(LoadName), stream, leaveOpen)
828828
{
829829
}
@@ -904,7 +904,7 @@ private BinaryLoader(IHost host, ModelLoadContext ctx, Stream stream)
904904
}
905905
}
906906

907-
public static BinaryLoader Create(IHostEnvironment env, ModelLoadContext ctx, IMultiStreamSource files)
907+
private static BinaryLoader Create(IHostEnvironment env, ModelLoadContext ctx, IMultiStreamSource files)
908908
{
909909
Contracts.CheckValue(env, nameof(env));
910910
IHost h = env.Register(LoadName);
@@ -940,7 +940,7 @@ public static BinaryLoader Create(IHostEnvironment env, ModelLoadContext ctx, IM
940940
/// Creates a binary loader from a stream that is not owned by the loader.
941941
/// This creates its own independent copy of input stream for the binary loader.
942942
/// </summary>
943-
public static BinaryLoader Create(IHostEnvironment env, ModelLoadContext ctx, Stream stream)
943+
private static BinaryLoader Create(IHostEnvironment env, ModelLoadContext ctx, Stream stream)
944944
{
945945
Contracts.CheckValue(env, nameof(env));
946946
IHost h = env.Register(LoadName);

Diff for: src/Microsoft.ML.Data/DataLoadSave/Binary/BinaryLoaderSaverCatalog.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ namespace Microsoft.ML
1111
public static class BinaryLoaderSaverCatalog
1212
{
1313
/// <summary>
14-
/// Read a data view from a Stream on a binary file using <see cref="BinaryLoader"/>.
14+
/// Read a data view from an <see cref="IMultiStreamSource"/> on a binary file using <see cref="BinaryLoader"/>.
1515
/// </summary>
1616
/// <param name="catalog">The catalog.</param>
17-
/// <param name="stream">The stream to read from.</param>
18-
public static IDataView ReadFromBinary(this DataOperations catalog, Stream stream)
17+
/// <param name="fileSource">The file source to read from. This can be a <see cref="MultiFileSource"/>, for example.</param>
18+
public static IDataView ReadFromBinary(this DataOperations catalog, IMultiStreamSource fileSource)
1919
{
20-
Contracts.CheckValue(stream, nameof(stream));
20+
Contracts.CheckValue(fileSource, nameof(fileSource));
2121

2222
var env = catalog.GetEnvironment();
2323

24-
var reader = new BinaryLoader(env, new BinaryLoader.Arguments(), stream);
24+
var reader = new BinaryLoader(env, new BinaryLoader.Arguments(), fileSource);
2525
return reader;
2626
}
2727

0 commit comments

Comments
 (0)