Skip to content

Commit

Permalink
Merge pull request #184 from FizzCodeSoftware/dev
Browse files Browse the repository at this point in the history
file sink buffer size
  • Loading branch information
wickedmachinator authored Nov 9, 2024
2 parents b582afa + 932de17 commit 8471958
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion EtLast.LocalFiles/Streams/LocalFileSinkProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public class LocalFileSinkProvider : IOneSinkProvider
/// </summary>
public FileShare FileShare { get; init; } = FileShare.Read;

/// <summary>
/// Default value is 4096.
/// </summary>
public int BufferSize { get; init; } = 4096;

public bool AutomaticallyDispose => true;

public static LocalFileSinkProvider CreateOrOverwrite(string path) => new()
Expand Down Expand Up @@ -106,7 +111,7 @@ public NamedSink GetSink(IProcess caller, string sinkFormat, string[] columns)
try
{
var sink = caller.Context.GetSink(System.IO.Path.GetDirectoryName(Path), System.IO.Path.GetFileName(Path), sinkFormat, caller, columns);
var stream = new FileStream(Path, FileMode, FileAccess, FileShare);
var stream = new FileStream(Path, FileMode, FileAccess, FileShare, BufferSize);
var namedSink = new NamedSink(PathHelpers.GetFriendlyPathName(Path), stream, ioCommand, sink);
SinkMetadataEnricher?.Enrich(namedSink.Sink);
return namedSink;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public class LocalFilesInDirectoryStreamProvider : IManyStreamProvider
/// </summary>
public bool ThrowExceptionWhenFileNotFound { get; init; } = true;

/// <summary>
/// Default value is 4096.
/// </summary>
public int BufferSize { get; init; } = 4096;

public IEnumerable<NamedStream> GetStreams(IProcess caller)
{
var paths = new List<string>();
Expand Down Expand Up @@ -75,7 +80,7 @@ private NamedStream GetFileStream(IProcess caller, string path)

try
{
var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, BufferSize);
return new NamedStream(path, stream, ioCommand);
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public class PartitionedLocalFileSinkProvider : IPartitionedSinkProvider
/// </summary>
public FileShare FileShare { get; init; } = FileShare.Read;

/// <summary>
/// Default value is 4096.
/// </summary>
public int BufferSize { get; init; } = 4096;

public bool AutomaticallyDispose => true;

public NamedSink GetSink(IProcess caller, string partitionKey, string sinkFormat, string[] columns)
Expand Down Expand Up @@ -103,7 +108,7 @@ public NamedSink GetSink(IProcess caller, string partitionKey, string sinkFormat
try
{
var sink = caller.Context.GetSink(Path.GetDirectoryName(path), Path.GetFileName(path), sinkFormat, caller, columns);
var stream = new FileStream(path, FileMode, FileAccess, FileShare);
var stream = new FileStream(path, FileMode, FileAccess, FileShare, BufferSize);
var namedSink = new NamedSink(PathHelpers.GetFriendlyPathName(path), stream, ioCommand, sink);
SinkMetadataEnricher?.Enrich(namedSink.Sink);
return namedSink;
Expand Down

0 comments on commit 8471958

Please sign in to comment.