feat(ipc): zero-copy pull-based BufferStreamReader #11374
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
rustyconover
Which issue does this PR close?
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::Bytesfrom object storage),StreamReader<R: Read>is the natural API to reach for, but it copies every message body into a fresh allocation.StreamDecoderfed a single ownedBufferis 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?
arrow_ipc::reader::BufferStreamReader: wrapsStreamDecoderwith an ownedBufferand implementsIterator<Item = Result<RecordBatch, ArrowError>>, likeStreamReader-
try_new(Buffer)andtry_new_from_bytes(bytes::Bytes); the schema is decoded eagerly soschema()is infallible- Like
StreamReader, a stream that ends on a message boundary without an EOS marker is accepted; a truncated message returns an errorStreamDecoder::is_finished()bytesadded as a direct dependency ofarrow-ipc(already a dependency ofarrow-buffer, so no new crate in the dependency tree)Are these changes tested?
Yes:
bytes::Bytesconstructor and a doctestAre there any user-facing changes?
New public APIs:
BufferStreamReaderandStreamDecoder::is_finished. No breaking changes.Written with AI assistance; all changes reviewed by the author.
🤖 Generated with Claude Code