-
Notifications
You must be signed in to change notification settings - Fork 315
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
FileSystem extension skeleton #787
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
7c25fcb
Basic FileSystem implementation
cc8237f
Move to extension
f4e141b
Todo
bcde071
Tests should run
06d8b24
Don't use interface
dfad910
Update src/csharp/Extensions/Microsoft.Spark.Extensions.FileSystem/Jv…
AFFogarty 50bc611
Remove IsPackable
00d68a6
Fixed: Line length 110
ec52232
Update src/csharp/Extensions/Microsoft.Spark.Extensions.FileSystem/Fi…
AFFogarty 4adbb64
Update src/csharp/Extensions/Microsoft.Spark.Extensions.FileSystem/Fi…
AFFogarty 16abe0a
Separate testing for signature and functionality
3310897
Merge
d79e702
Fixed: Test the type of FileSystem
bd8579b
Fixed: Empty line
a3bf508
Rename to Hadoop.FileSystem
4fc9718
Rename references
1bacdb2
Move to correct dir
53351a6
Merge implementation with abstract class
ac57039
Better comment
8a85d60
Fixed: Line length
9936e9f
Merge new files into existing project
c896d63
Fix references
e1f33e8
Fixed: return message
a856829
Merge branch 'master' of https://github.com/dotnet/spark into anfog/1…
6433b3c
Update src/csharp/Microsoft.Spark/Hadoop/FS/FileSystem.cs
AFFogarty 4b906e0
Merge branch 'anfog/1201_filesystem' of https://github.com/AFFogarty/…
dcf07d5
Compiles
e41e1ef
Casing fix -- part 1
f798618
Casing fix -- part 2
8cc2378
Don't need to test assignable
74ce69d
Formatting
257ce6c
Fixed: Don't commi test app
9f92c7d
Merge branch 'master' of https://github.com/dotnet/spark into anfog/1…
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 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 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 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
56 changes: 56 additions & 0 deletions
56
src/csharp/Microsoft.Spark.E2ETest/Hadoop/FileSystemTests.cs
This file contains 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.IO; | ||
using Microsoft.Spark.Hadoop.Fs; | ||
using Microsoft.Spark.Sql; | ||
using Microsoft.Spark.UnitTest.TestUtils; | ||
using Xunit; | ||
|
||
namespace Microsoft.Spark.E2ETest.Hadoop | ||
{ | ||
[Collection("Spark E2E Tests")] | ||
public class FileSystemTests | ||
{ | ||
private readonly SparkSession _spark; | ||
|
||
public FileSystemTests(SparkFixture fixture) | ||
{ | ||
_spark = fixture.Spark; | ||
} | ||
|
||
/// <summary> | ||
/// Test that methods return the expected signature. | ||
/// </summary> | ||
[Fact] | ||
public void TestSignatures() | ||
{ | ||
using var tempDirectory = new TemporaryDirectory(); | ||
|
||
using FileSystem fs = FileSystem.Get(_spark.SparkContext.HadoopConfiguration()); | ||
|
||
Assert.IsType<bool>(fs.Delete(tempDirectory.Path, true)); | ||
} | ||
|
||
/// <summary> | ||
/// Test that Delete() deletes the file. | ||
/// </summary> | ||
[Fact] | ||
public void TestDelete() | ||
{ | ||
using FileSystem fs = FileSystem.Get(_spark.SparkContext.HadoopConfiguration()); | ||
|
||
using var tempDirectory = new TemporaryDirectory(); | ||
string path = Path.Combine(tempDirectory.Path, "temp-table"); | ||
_spark.Range(25).Write().Format("parquet").Save(path); | ||
|
||
Assert.True(Directory.Exists(path)); | ||
|
||
Assert.True(fs.Delete(path, true)); | ||
Assert.False(fs.Delete(path, true)); | ||
|
||
Assert.False(Directory.Exists(path)); | ||
} | ||
} | ||
} |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Microsoft.Spark.Interop.Ipc; | ||
|
||
namespace Microsoft.Spark.Hadoop.Conf | ||
{ | ||
/// <summary> | ||
/// Provides access to configuration parameters. | ||
/// </summary> | ||
public class Configuration : IJvmObjectReferenceProvider | ||
{ | ||
private readonly JvmObjectReference _jvmObject; | ||
|
||
internal Configuration(JvmObjectReference jvmObject) | ||
{ | ||
_jvmObject = jvmObject; | ||
} | ||
|
||
JvmObjectReference IJvmObjectReferenceProvider.Reference => _jvmObject; | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using Microsoft.Spark.Hadoop.Conf; | ||
using Microsoft.Spark.Interop; | ||
using Microsoft.Spark.Interop.Ipc; | ||
|
||
namespace Microsoft.Spark.Hadoop.Fs | ||
{ | ||
/// <summary> | ||
/// A fairly generic filesystem. It may be implemented as a distributed filesystem, or as a "local" one | ||
/// that reflects the locally-connected disk. The local version exists for small Hadoop instances and for | ||
/// testing. | ||
/// | ||
/// All user code that may potentially use the Hadoop Distributed File System should be written to use a | ||
/// FileSystem object. The Hadoop DFS is a multi-machine system that appears as a single disk. It's | ||
/// useful because of its fault tolerance and potentially very large capacity. | ||
/// </summary> | ||
public class FileSystem : IJvmObjectReferenceProvider, IDisposable | ||
{ | ||
private readonly JvmObjectReference _jvmObject; | ||
|
||
internal FileSystem(JvmObjectReference jvmObject) | ||
{ | ||
_jvmObject = jvmObject; | ||
} | ||
|
||
JvmObjectReference IJvmObjectReferenceProvider.Reference => _jvmObject; | ||
|
||
/// <summary> | ||
/// Returns the configured <see cref="FileSystem"/>. | ||
/// </summary> | ||
/// <param name="conf">The configuration to use.</param> | ||
/// <returns>The FileSystem.</returns> | ||
public static FileSystem Get(Configuration conf) => | ||
new FileSystem((JvmObjectReference)SparkEnvironment.JvmBridge.CallStaticJavaMethod( | ||
"org.apache.hadoop.fs.FileSystem", | ||
"get", | ||
conf)); | ||
|
||
/// <summary> | ||
/// Delete a file. | ||
/// </summary> | ||
/// <param name="path">The path to delete.</param> | ||
/// <param name="recursive">If path is a directory and set to true, the directory is deleted else | ||
/// throws an exception. In case of a file the recursive can be set to either true or false.</param> | ||
/// <returns>True if delete is successful else false.</returns> | ||
public bool Delete(string path, bool recursive = true) | ||
{ | ||
JvmObjectReference pathObject = | ||
SparkEnvironment.JvmBridge.CallConstructor("org.apache.hadoop.fs.Path", path); | ||
|
||
return (bool)_jvmObject.Invoke("delete", pathObject, recursive); | ||
} | ||
|
||
public void Dispose() => _jvmObject.Invoke("close"); | ||
} | ||
} |
This file contains 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
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.
@imback82 Not sure if this should be a function or a property.
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.
Since this is
def
on the Scala side, this will be a method on C# side. So the current approach is good.