[#23] Client: Refactoring to optimize memory usage
Signed-off-by: Pavel Gross <p.gross@yando.com>
This commit is contained in:
parent
1a02ac2ae7
commit
6562aa27a5
141 changed files with 1722 additions and 896 deletions
|
@ -4,7 +4,6 @@ using System.Threading.Tasks;
|
|||
using Grpc.Core;
|
||||
|
||||
using FrostFS.Object;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using System.Threading;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
@ -33,7 +32,7 @@ public class ObjectReader(AsyncServerStreamingCall<GetResponse> call) : IObjectR
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<byte[]?> ReadChunk(CancellationToken cancellationToken = default)
|
||||
public async Task<ReadOnlyMemory<byte>?> ReadChunk(CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (!await Call.ResponseStream.MoveNext(cancellationToken))
|
||||
return null;
|
||||
|
@ -44,14 +43,14 @@ public class ObjectReader(AsyncServerStreamingCall<GetResponse> call) : IObjectR
|
|||
if (response.Body.ObjectPartCase != GetResponse.Types.Body.ObjectPartOneofCase.Chunk)
|
||||
throw new InvalidOperationException("unexpected message type");
|
||||
|
||||
return response.Body.Chunk.ToByteArray();
|
||||
return response.Body.Chunk.Memory;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
Call.Dispose();
|
||||
Call?.Dispose();
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
disposed = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue