Adding `Span<byte>` / `Memory<byte>` API support to IStore
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- csharp
- Área
- backend-api-design, cloud
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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 ?
- Lenguaje dominante
- C#
- Estrellas
- 464
- Forks
- 78
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de robinrodricks/FluentStorage
-
Azure Blob bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
robinrodricks/FluentStorage#179 · 1 comentario ·
-
question
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
robinrodricks/FluentStorage#178 · 7 comentarios ·
-
discussion help wanted
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
robinrodricks/FluentStorage#148 ·
-
response requested Wasabi
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
robinrodricks/FluentStorage#121 · 2 comentarios ·
-
maintainance work in progress
Dificultad 3/5 1-2 días Aptitud para principiantes 54/100
robinrodricks/FluentStorage#111 · 2 comentarios ·
Todos los issues de robinrodricks/FluentStorage
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
SixLabors/ImageSharp.Drawing#438 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 92/100
NetSparkleUpdater/NetSparkle#762 ·
-
ANSIInitializer.Enabled getterAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
-
bug effort:S P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
nightscout/nocturne#4563 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Tyrrrz/YoutubeDownloader#925 ·