Adding `Span<byte>` / `Memory<byte>` API support to IStore
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- csharp
- Ambito
- backend-api-design, cloud
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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 ?
- Lingua principale
- C#
- Stelle
- 464
- Fork
- 78
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di robinrodricks/FluentStorage
-
Azure Blob bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
robinrodricks/FluentStorage#179 · 1 commento ·
-
question
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
robinrodricks/FluentStorage#178 · 7 commenti ·
-
discussion help wanted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
robinrodricks/FluentStorage#148 ·
-
response requested Wasabi
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
robinrodricks/FluentStorage#121 · 2 commenti ·
-
maintainance work in progress
Difficoltà 3/5 1-2 giorni Idoneità per principianti 54/100
robinrodricks/FluentStorage#111 · 2 commenti ·
Tutte le issue di robinrodricks/FluentStorage
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
bug effort:S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
nightscout/nocturne#4563 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
KnifeLemon/Filee#1887 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno