Adding `Span<byte>` / `Memory<byte>` API support to IStore
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- csharp
調査の方向性
Start by reading the IStore API and the IBlobStorage implementations that currently accept byte[]; the issue does not name specific files or tests. Compare the proposed default interface method and extension method approaches, then determine how the API and implementations can accept Memory<byte> or Span<byte> while preserving existing callers. Done means the chosen API supports the requested buffer usage and the storage implementations are covered.
索引モデルが issue の本文から書いたものです。
説明
Hi !
Is there any plan on adding support of Span<byte> / Memory<byte> where byte[] is currently required ?
(given that the introduction of these types help enhance memory usage and are spreading across the SDK)
Here a example where I think having overloads that accepts Span or Memory depending on the context could help
Memory<byte> buffer = GetBuffer();
Guid id = Guid.NewGuid();
string fileName = section.FileName;
string fullPath = $"upload/{id}";
Stream stream = section.Section.Body;
int bytesRead = 0;
// Streaming of the file
do
{
bytesRead = await stream.ReadAsync(buffer.Memory, ct);
await _storage.WriteAsync(fullPath, buffer.Memory.ToArray(), true, cancellationToken: ct);
}
while (bytesRead > 0);
which could be rewritten
Memory<byte> buffer = GetBuffer();
Guid id = Guid.NewGuid();
string fileName = section.FileName;
string fullPath = $"upload/{id}";
Stream stream = section.Section.Body;
int bytesRead = 0;
// Streaming of the file
do
{
bytesRead = await stream.ReadAsync(buffer.Memory, ct);
await _storage.WriteAsync(fullPath, buffer.Memory, true, cancellationToken: ct);
}
while (bytesRead > 0);
From what i've seen in the codebase, it would require to either :
- go through all existing
IBlobStorageimplementations to add support for this but with a default interface implementation, the change could be as minimal as adding default method
Task WriteAsync(string fullPath, Memory<byte> data, bool append = false, CancellationToken cancellationToken = default) => WriteAsync(fullPath, new MemoryStream(data.ToArray()), append, cancellationToken);
This has the advantage of allowing implementors to provide a more memory efficient approach without breaking them (net6.0 upwards)
- add a new
IBlobStorage.WriteAsyncextension method that would take aMemory<byte>instead ofbyte[]
Is that something that make sense to you ?
- 主要言語
- C#
- スター
- 464
- フォーク
- 78
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
robinrodricks/FluentStorage のほかの issue
-
Azure Blob bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
robinrodricks/FluentStorage#179 · コメント 1 件 ·
-
question
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
robinrodricks/FluentStorage#178 · コメント 7 件 ·
-
discussion help wanted
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
robinrodricks/FluentStorage#148 ·
-
response requested Wasabi
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
robinrodricks/FluentStorage#121 · コメント 2 件 ·
-
maintainance work in progress
難易度 3/5 1〜2日 初心者へのやさしさ 54/100
robinrodricks/FluentStorage#111 · コメント 2 件 ·
robinrodricks/FluentStorage の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
SixLabors/ImageSharp.Drawing#438 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
NetSparkleUpdater/NetSparkle#762 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
bug effort:S P3
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
nightscout/nocturne#4563 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Tyrrrz/YoutubeDownloader#925 ·