Skip to content

Commit 03fade6

Browse files
tyclintwshauheen
authored andcommitted
Add PartitionedFileLoader (dotnet#61)
1 parent 278b1a3 commit 03fade6

29 files changed

+1922
-343
lines changed

src/Microsoft.ML.Core/Utilities/PathUtils.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -67,13 +67,17 @@ public static string FindExistentFileOrNull(string fileName, string folderPrefix
6767
// 1. Search in customSearchDir.
6868
if (!string.IsNullOrWhiteSpace(customSearchDir)
6969
&& TryFindFile(fileName, folderPrefix, customSearchDir, out candidate))
70-
return candidate;
70+
{
71+
return candidate;
72+
}
7173

7274
// 2. Search in the path specified by the environment variable.
7375
var envDir = Environment.GetEnvironmentVariable(CustomSearchDirEnvVariable);
7476
if (!string.IsNullOrWhiteSpace(envDir)
7577
&& TryFindFile(fileName, folderPrefix, envDir, out candidate))
76-
return candidate;
78+
{
79+
return candidate;
80+
}
7781

7882
// 3. Search in the path specified by the assemblyForBasePath.
7983
if (assemblyForBasePath != null)

src/Microsoft.ML.Data/Commands/DataCommand.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,20 @@ public static void SaveLoader(IDataLoader loader, IFileHandle file)
396396
Contracts.CheckParam(file.CanWrite, nameof(file), "Must be writable");
397397

398398
using (var stream = file.CreateWriteStream())
399+
{
400+
SaveLoader(loader, stream);
401+
}
402+
}
403+
404+
/// <summary>
405+
/// Saves <paramref name="loader"/> to the specified <paramref name="stream"/>.
406+
/// </summary>
407+
public static void SaveLoader(IDataLoader loader, Stream stream)
408+
{
409+
Contracts.CheckValue(loader, nameof(loader));
410+
Contracts.CheckValue(stream, nameof(stream));
411+
Contracts.CheckParam(stream.CanWrite, nameof(stream), "Must be writable");
412+
399413
using (var rep = RepositoryWriter.CreateNew(stream))
400414
{
401415
ModelSaveContext.SaveModel(rep, loader, ModelFileUtils.DirDataLoaderModel);

0 commit comments

Comments
 (0)