apache / apache/arrow-rs

`split_batch_for_grpc_response` over-splits batches after IPC deserialization

Open
#9,388 2 comments 0 reactions 1 assignee Claimed by @Rich-T-kid View on GitHub
bug
Dominant language
Rust
Stars
3.6k
Forks
1.3k
Avg merge
2d 18h
Merged PRs (30d)
169

Description

**Describe the bug**

`split_batch_for_grpc_response` uses [this](https://github.com/apache/arrow-rs/blob/54d81919206d667d36ba4b5f76ff8e7ed9d341dd/arrow-flight/src/encode.rs#L621) to estimate batch size for splitting. This calls buffer.capacity(), which reports the full backing allocation size, not the actual data size.
After IPC deserialization, the IPC reader creates all buffers by slicing one shared `Buffer` via [this](https://github.com/apache/arrow-rs/blob/54d81919206d667d36ba4b5f76ff8e7ed9d341dd/arrow-buffer/src/buffer/immutable.rs#L298-L312), which clones the Arc. So every buffer's capacity() reports the entire message body size rather than its own slice.

**To Reproduce**

`FlightDataEncoderBuilder` encode -> `FlightRecordBatchStream` decode -> `FlightDataEncoderBuilder` re-encode produces more FlightData than just `FlightDataEncoderBuilder` encode

**Expected behavior**

**Additional context**

#5352

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.