Skip to content

Why RawStream contains an Iterator of Vec<u8> instead of std::io::Read? #7017

Closed

Description

@Kixunil

Question

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.

Activity

  1. added
    deprecated:question
    on Nov 5, 2022
  2. rgwood commented on Dec 2, 2022

    @rgwood
    Contributor

    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 Read trait like that, feel free.

    pub stream: Box<dyn Iterator<Item = Result<Vec<u8>, ShellError>> + Send + 'static>,

  3. added
    A:streaming
    on Mar 1, 2023
  4. added a commit that references this issue on May 16, 2024
    6fd854e
  5. added this to the v0.94.0 milestone on May 17, 2024
  6. added a commit that references this issue on May 18, 2024
    af1c34b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:streamingdeprecated:question

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions