Skip to content

[Rust] Expose Arrow batch encoded byte sizes - #790

Open
flaviofcruz wants to merge 1 commit into
mainfrom
rust-arrow-batch-byte-size
Open

[Rust] Expose Arrow batch encoded byte sizes#790
flaviofcruz wants to merge 1 commit into
mainfrom
rust-arrow-batch-byte-size

Conversation

@flaviofcruz

Copy link
Copy Markdown
Collaborator

What changes are proposed in this pull request?

Add ZerobusArrowStream::take_offset_details, returning Some(OffsetDetails) with the encoded wire byte size of the batch at an offset and the cumulative wire bytes sent through it. Callers report an accurate bytes-sent metric without re-serialising the RecordBatch (issue #779); None when no size is recorded.

To make this happen, we carry the OffsetId alongside the RecordBatch so that we can encode the size. The stats recorder keeps only a certain amount of stats so if they are not consumed, the user won't be able to recover them, so they have to be consumed after waiting for the offset.

This change will be used to track the vector's databricks_zerobus bytes sent which is helpful to debug what is happening.

An alternative design that was considered was to introduce a separate wait_for_offset called wait_for_offset_with_details which waits for the offset and then immediately returns the stats. The downside is that we end up with multiple similar functions but can do that if you feel that's better.

How is this tested?

Added several unit tests.

Add ZerobusArrowStream::take_offset_details, returning Some(OffsetDetails)
with the encoded wire byte size of the batch at an offset and the cumulative
wire bytes sent through it. Callers report an accurate bytes-sent metric
without re-serialising the RecordBatch (issue #779); None when no size is
recorded.

The batch channel now carries each batch's OffsetId alongside the RecordBatch,
so the Flight encoder records byte sizes keyed by the durable OffsetId with no
per-connection offset reconstruction. Per-offset and cumulative sizes accumulate
every transmission, counting retransmits; a batch encoded as several IPC messages
(e.g. a dictionary batch) sums against the same offset. State lives in a bounded
BatchStatsTracker; reads are consume-once.

Additive: wait_for_offset/flush and the FFI/JNI/PyO3 surfaces are unchanged.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Flavio Cruz <flavio.cruz@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant