question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for `ReadOnlySequence<byte>` and `IBufferWriter<byte>`

See original GitHub issue

I’m happy to see support for ReadOnlySpan<byte> already in the library.

I want to be able to effectively stream compression/decompression, but without using the Stream class. That is, I don’t want to have to allocate contiguous memory for the input and output of the algorithm.

If the algorithm would accept a ReadOnlySequence<byte> as input, and write its output to a given IBufferWriter<byte> instance, then I can for instance process 1GB of data without having to have found 2 blocks of 1GB of contiguous memory to allocate arrays. Instead, these two types allow for breaking up the input/output into much more conveniently sized blocks.

Can such support be added? I can already do this on top of your Stream APIs, but doing it natively would presumably be at least a bit more efficient, and possibly(?) avoid the extra dependency you have on your stream-supporting package.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:31 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
MiloszKrajewskicommented, Nov 6, 2022

I’m closing this issue at addressed with 1.3.3. This ticket was very valuable, and I guess it can spawn a discussion about rewrite. But for now: it does support ReadOnlySequence<byte> and IBufferWriter<byte> as source/target on encoding/decoding, so goal has been achieved.

1reaction
rmjacommented, Sep 13, 2022

Year, exactly. That was my point. @MiloszKrajewski is it ok if I come with a proposal for this that we can use as a basis for a discussion? I think that work from here on is better in a draft pr than a gist.

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.Buffers - .NET
Requests a buffer of at least 5 bytes from the IBufferWriter<byte> using GetSpan(5) . · Writes bytes for the ASCII string "Hello" to...
Read more >
I/O Enhancements | .NEXT
Ability to represent written content as ReadOnlySequence<byte> if it's too large for representation in the form of Memory<byte> data type. The last two...
Read more >
A better way to copy a ReadOnlySequence<byte> to a Struct
Yes, that's right, the ReadOnlySequence<byte> comes out of the System.IO.Pipeline.PipeReader , it's the only way that the buffer is provided.
Read more >
How to make the fastest .NET Serializer with .NET 7 / C# 11 ...
Support for IBufferWriter<byte> is a prerequisite for modern serializers, as it offers higher performance than using byte[] or Stream.
Read more >
com.cysharp.memorypack
Support modern I/O APIs ( IBufferWriter<byte> , ReadOnlySpan<byte> , ReadOnlySequence<byte> ); Native AOT friendly Source Generator based code generation, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found