← Back to Pull requests

feat(ipc): zero-copy pull-based BufferStreamReader #11374

Open
unknown opened this pull request with 251 lines diff across 3 files
View on GitHub
unknown unknown commented on Oct 04, 2026 15:18 UTC
Author

Which issue does this PR close?

  • Closes #9837.
  • Rationale for this change

    When an entire IPC stream is already in memory (an HTTP body, a memory-mapped file, a shared-memory segment, or bytes::Bytes from object storage), StreamReader<R: Read> is the natural API to reach for, but it copies every message body into a fresh allocation. StreamDecoder fed a single owned Buffer is already zero-copy, since it slices the input for each column buffer, but it has a push-based API that is awkward for this case.

    Microbenchmark (Float64Array, 10M rows, in-memory stream, see #9837):

    | reader | time | throughput |
    |---|---|---|
    | StreamReader<Cursor<&[u8]>> | 33 ms | 2.4 GB/s |
    | StreamDecoder + Buffer | 0.004 ms | (aliases input) |

    What changes are included in this PR?

  • New arrow_ipc::reader::BufferStreamReader: wraps StreamDecoder with an owned Buffer and implements Iterator<Item = Result<RecordBatch, ArrowError>>, like StreamReader

  • - try_new(Buffer) and try_new_from_bytes(bytes::Bytes); the schema is decoded eagerly so schema() is infallible
    - Like StreamReader, a stream that ends on a message boundary without an EOS marker is accepted; a truncated message returns an error
  • New StreamDecoder::is_finished()

  • bytes added as a direct dependency of arrow-ipc (already a dependency of arrow-buffer, so no new crate in the dependency tree)
  • Are these changes tested?

    Yes:

  • Single and multi-batch round-trips, a schema-only stream, and dictionary-encoded batches

  • A pointer-aliasing test confirming the returned column buffer points inside the input allocation

  • An empty buffer, a stream without an EOS marker, and a truncated message

  • The bytes::Bytes constructor and a doctest
  • Are there any user-facing changes?

    New public APIs: BufferStreamReader and StreamDecoder::is_finished. No breaking changes.

    Written with AI assistance; all changes reviewed by the author.

    🤖 Generated with Claude Code

    Diff: 251 lines (+188 / -63) across 3 files Reviewer: rustyconover Review duration: 82120m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.51) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.51 · 251 lines diff across 3 files
    0.51
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.331
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #11374"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 51% (MEDIUM) · Higher = larger blast radius
    51%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 28.2% · Safe to merge
    28.2%