Adding `Span<byte>` / `Memory<byte>` API support to IStore
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- csharp
- Lĩnh vực
- backend-api-design, cloud
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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 ?
- Ngôn ngữ chính
- C#
- Star
- 464
- Fork
- 78
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của robinrodricks/FluentStorage
-
Azure Blob bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
robinrodricks/FluentStorage#179 · 1 bình luận ·
-
question
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
robinrodricks/FluentStorage#178 · 7 bình luận ·
-
discussion help wanted
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
robinrodricks/FluentStorage#148 ·
-
response requested Wasabi
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
robinrodricks/FluentStorage#121 · 2 bình luận ·
-
maintainance work in progress
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 54/100
robinrodricks/FluentStorage#111 · 2 bình luận ·
Tất cả issue của robinrodricks/FluentStorage
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
SixLabors/ImageSharp.Drawing#438 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
NetSparkleUpdater/NetSparkle#762 ·
-
ANSIInitializer.Enabled getterĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
bug effort:S P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
nightscout/nocturne#4563 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Tyrrrz/YoutubeDownloader#925 ·