Skip to content

Commit ce4638f

Browse files
Storage Internals Rename (Azure#13589)
Renamed internal class StreamSlice to SlicedStream per naming guidelines. Deleted a duplicate class from testing.
1 parent 65d09d7 commit ce4638f

File tree

8 files changed

+17
-80
lines changed

8 files changed

+17
-80
lines changed

sdk/storage/Azure.Storage.Blobs/src/Azure.Storage.Blobs.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<Compile Include="$(AzureStorageSharedSources)SasExtensions.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
5656
<Compile Include="$(AzureStorageSharedSources)SasQueryParametersInternals.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
5757
<Compile Include="$(AzureStorageSharedSources)SharedAccessSignatureCredentials.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
58+
<Compile Include="$(AzureStorageSharedSources)SlicedStream.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
5859
<Compile Include="$(AzureStorageSharedSources)StorageClientOptions.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
5960
<Compile Include="$(AzureStorageSharedSources)StorageConnectionString.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
6061
<Compile Include="$(AzureStorageSharedSources)StorageCollectionEnumerator.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
@@ -66,7 +67,6 @@
6667
<Compile Include="$(AzureStorageSharedSources)StorageSharedKeyPipelinePolicy.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
6768
<Compile Include="$(AzureStorageSharedSources)StorageResponseClassifier.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
6869
<Compile Include="$(AzureStorageSharedSources)StorageVersionExtensions.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
69-
<Compile Include="$(AzureStorageSharedSources)StreamSlice.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
7070
<Compile Include="$(AzureStorageSharedSources)UriExtensions.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
7171
<Compile Include="$(AzureStorageSharedSources)UriQueryParamsCollection.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
7272
<Compile Include="$(AzureStorageSharedSources)UserDelegationKeyProperties.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />

sdk/storage/Azure.Storage.Common/src/Shared/PartitionedUploader.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal class PartitionedUploader<TServiceSpecificArgs, TCompleteUploadReturn>
1717
{
1818
#region Definitions
1919
// delegte for getting a partition from a stream based on the selected data management stragegy
20-
private delegate Task<StreamSlice> GetNextStreamPartition(
20+
private delegate Task<SlicedStream> GetNextStreamPartition(
2121
Stream stream,
2222
long minCount,
2323
long maxCount,
@@ -260,7 +260,7 @@ private async Task<Response<TCompleteUploadReturn>> UploadInSequenceInternal(
260260
// Partition the stream into individual blocks and stage them
261261
if (async)
262262
{
263-
await foreach (StreamSlice block in GetPartitionsAsync(
263+
await foreach (SlicedStream block in GetPartitionsAsync(
264264
content,
265265
contentLength,
266266
partitionSize,
@@ -281,7 +281,7 @@ await StagePartitionAndDisposeInternal(
281281
}
282282
else
283283
{
284-
foreach (StreamSlice block in GetPartitionsAsync(
284+
foreach (SlicedStream block in GetPartitionsAsync(
285285
content,
286286
contentLength,
287287
partitionSize,
@@ -350,7 +350,7 @@ private async Task<Response<TCompleteUploadReturn>> UploadInParallelAsync(
350350
List<Task> runningTasks = new List<Task>();
351351

352352
// Partition the stream into individual blocks
353-
await foreach (StreamSlice block in GetPartitionsAsync(
353+
await foreach (SlicedStream block in GetPartitionsAsync(
354354
content,
355355
contentLength,
356356
blockSize,
@@ -420,7 +420,7 @@ private async Task<Response<TCompleteUploadReturn>> UploadInParallelAsync(
420420
/// Wraps both the async method and dispose call in one task.
421421
/// </summary>
422422
private async Task StagePartitionAndDisposeInternal(
423-
StreamSlice partition,
423+
SlicedStream partition,
424424
long offset,
425425
TServiceSpecificArgs args,
426426
IProgress<long> progressHandler,
@@ -469,7 +469,7 @@ await _uploadPartitionInternal(
469469
/// <summary>
470470
/// Partition a stream into a series of blocks buffered as needed by an array pool.
471471
/// </summary>
472-
private static async IAsyncEnumerable<StreamSlice> GetPartitionsAsync(
472+
private static async IAsyncEnumerable<SlicedStream> GetPartitionsAsync(
473473
Stream stream,
474474
long? streamLength,
475475
long blockSize,
@@ -502,7 +502,7 @@ private static async IAsyncEnumerable<StreamSlice> GetPartitionsAsync(
502502
long absolutePosition = 0;
503503
do
504504
{
505-
StreamSlice partition = await getNextPartition(
505+
SlicedStream partition = await getNextPartition(
506506
stream,
507507
acceptableBlockSize,
508508
blockSize,
@@ -552,7 +552,7 @@ private static async IAsyncEnumerable<StreamSlice> GetPartitionsAsync(
552552
/// <returns>
553553
/// Task containing the buffered stream partition.
554554
/// </returns>
555-
private async Task<StreamSlice> GetBufferedPartitionInternal(
555+
private async Task<SlicedStream> GetBufferedPartitionInternal(
556556
Stream stream,
557557
long minCount,
558558
long maxCount,
@@ -594,14 +594,14 @@ private async Task<StreamSlice> GetBufferedPartitionInternal(
594594
/// <returns>
595595
/// Task containing the stream facade.
596596
/// </returns>
597-
private static Task<StreamSlice> GetStreamedPartitionInternal(
597+
private static Task<SlicedStream> GetStreamedPartitionInternal(
598598
Stream stream,
599599
long minCount,
600600
long maxCount,
601601
long absolutePosition,
602602
bool async,
603603
CancellationToken cancellationToken)
604-
=> Task.FromResult((StreamSlice)WindowStream.GetWindow(stream, maxCount, absolutePosition));
604+
=> Task.FromResult((SlicedStream)WindowStream.GetWindow(stream, maxCount, absolutePosition));
605605
#endregion
606606
}
607607
}

sdk/storage/Azure.Storage.Common/src/Shared/PooledMemoryStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Azure.Storage.Shared
1515
/// Functions like a readable <see cref="MemoryStream"/> but uses an ArrayPool to supply the backing memory.
1616
/// This stream support buffering long sizes.
1717
/// </summary>
18-
internal class PooledMemoryStream : StreamSlice
18+
internal class PooledMemoryStream : SlicedStream
1919
{
2020
private const int DefaultMaxArrayPoolRentalSize = 128 * Constants.MB;
2121

sdk/storage/Azure.Storage.Common/src/Shared/StreamSlice.cs renamed to sdk/storage/Azure.Storage.Common/src/Shared/SlicedStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Azure.Storage.Shared
66
/// <summary>
77
/// Describes a stream that is a partition of another, larger stream.
88
/// </summary>
9-
internal abstract class StreamSlice : System.IO.Stream
9+
internal abstract class SlicedStream : System.IO.Stream
1010
{
1111
/// <summary>
1212
/// Absolute position of the start of this stream in the larger stream it was chunked from.

sdk/storage/Azure.Storage.Common/src/Shared/WindowStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Azure.Storage.Shared
1616
/// Exposes a predetermined slice of a larger stream using the same Stream interface.
1717
/// There should not be access to the base stream while this facade is in use.
1818
/// </summary>
19-
internal abstract class WindowStream : StreamSlice
19+
internal abstract class WindowStream : SlicedStream
2020
{
2121
private Stream InnerStream { get; }
2222

sdk/storage/Azure.Storage.Common/tests/Azure.Storage.Common.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<Compile Include="$(AzureStorageSharedSources)PartitionedUploader.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
2424
<Compile Include="$(AzureStorageSharedSources)PooledMemoryStream.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
2525
<Compile Include="$(AzureStorageSharedSources)ProgressIncrementingStream.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
26-
<Compile Include="$(AzureStorageSharedSources)StreamSlice.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
26+
<Compile Include="$(AzureStorageSharedSources)SlicedStream.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
2727
<Compile Include="$(AzureStorageSharedSources)WindowStream.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
2828
</ItemGroup>
2929
<!-- Ensure an empty TestConfigurations.xml is always present so the build can copy it -->

sdk/storage/Azure.Storage.Common/tests/PooledMemoryStreamTests.cs

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
using System;
54
using System.Buffers;
6-
using System.Collections.Generic;
7-
using System.IO;
85
using System.Linq;
9-
using System.Runtime.InteropServices.ComTypes;
10-
using System.Text;
116
using Azure.Core.Pipeline;
127
using Azure.Storage.Shared;
8+
using Azure.Storage.Tests.Shared;
139
using NUnit.Framework;
1410

1511
namespace Azure.Storage.Tests
@@ -19,65 +15,6 @@ public class PooledMemoryStreamTests
1915
{
2016
private readonly ArrayPool<byte> _pool = ArrayPool<byte>.Shared;
2117

22-
/// <summary>
23-
/// Stream who's byte at position n is n % <see cref="byte.MaxValue"/>.
24-
/// Note this means we have 255 possibilities, not 256, giving variation at likely buffer boundaries.
25-
/// </summary>
26-
private class PredictableStream : Stream
27-
{
28-
public override bool CanRead => true;
29-
30-
public override bool CanSeek => true;
31-
32-
public override bool CanWrite => false;
33-
34-
public override long Length => throw new NotSupportedException();
35-
36-
public override long Position { get; set; } = 0;
37-
38-
public override void Flush()
39-
{ }
40-
41-
public override int Read(byte[] buffer, int offset, int count)
42-
{
43-
for (int i = 0; i < count; i++)
44-
{
45-
buffer[offset + i] = (byte)((Position + i) % byte.MaxValue);
46-
}
47-
48-
Position += count;
49-
return count;
50-
}
51-
52-
public override long Seek(long offset, SeekOrigin origin)
53-
{
54-
switch (origin)
55-
{
56-
case SeekOrigin.Begin:
57-
Position = offset;
58-
break;
59-
case SeekOrigin.Current:
60-
Position += offset;
61-
break;
62-
case SeekOrigin.End:
63-
Position = Length + offset;
64-
break;
65-
}
66-
67-
return Position;
68-
}
69-
70-
public override void SetLength(long value)
71-
{
72-
throw new NotSupportedException();
73-
}
74-
75-
public override void Write(byte[] buffer, int offset, int count)
76-
{
77-
throw new NotSupportedException();
78-
}
79-
}
80-
8118
/// <summary>
8219
/// Sanity check for our test helper stream implementation.
8320
/// </summary>

sdk/storage/Azure.Storage.Files.DataLake/src/Azure.Storage.Files.DataLake.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<Compile Include="$(AzureStorageSharedSources)SasExtensions.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
5252
<Compile Include="$(AzureStorageSharedSources)SasQueryParametersInternals.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
5353
<Compile Include="$(AzureStorageSharedSources)SharedAccessSignatureCredentials.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
54+
<Compile Include="$(AzureStorageSharedSources)SlicedStream.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
5455
<Compile Include="$(AzureStorageSharedSources)StorageClientOptions.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
5556
<Compile Include="$(AzureStorageSharedSources)StorageConnectionString.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
5657
<Compile Include="$(AzureStorageSharedSources)StorageCollectionEnumerator.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
@@ -62,7 +63,6 @@
6263
<Compile Include="$(AzureStorageSharedSources)StorageSharedKeyPipelinePolicy.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
6364
<Compile Include="$(AzureStorageSharedSources)StorageResponseClassifier.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
6465
<Compile Include="$(AzureStorageSharedSources)StorageVersionExtensions.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
65-
<Compile Include="$(AzureStorageSharedSources)StreamSlice.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
6666
<Compile Include="$(AzureStorageSharedSources)UriExtensions.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
6767
<Compile Include="$(AzureStorageSharedSources)UriQueryParamsCollection.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />
6868
<Compile Include="$(AzureStorageSharedSources)UserDelegationKeyProperties.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />

0 commit comments

Comments
 (0)