You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Why RawStream contains an Iterator of Vec<u8> instead of std::io::Read? #7017
A:streamingIssues related to streaming data (or collecting data when it should be streamed)deprecated:questionQuestions should be redirected to GitHub discussions
RawStream is an iterator of heap-allocated chunks of bytes as opposed to std::io::Read which may harm performance in some cases. The only reason that comes to my mind is having a different error type but that could've been implemented by having a custom Read trait that's a copy of std::io::Read except for error bytes.
Is there any other reason I don' see? If not how hard would it be to refactor it?
Additional context and details
I started working on optimizing json objects parsing to not collect the whole stream into string as mentioned in #6979 (comment) and assumed it implements Read which is not the case. I even implemented a bunch of optimizations aiming at significantly reducing heap allocations. 🤦♂️ I'm now wondering how to proceed.
A:streamingIssues related to streaming data (or collecting data when it should be streamed)deprecated:questionQuestions should be redirected to GitHub discussions
Activity
rgwood commentedon Dec 2, 2022
Hi, I looked at this a bit and I'm not sure why we did it that way, sorry! If you want to try adding a new custom
Readtrait like that, feel free.nushell/crates/nu-protocol/src/value/stream.rs
Line 11 in cf0a18b
Replace `ExternalStream` with new `ByteStream` type (#12774)
Replace `ExternalStream` with new `ByteStream` type (nushell#12774)