Commit fab8e75
Add BinaryFormatSupport and Row Encoder to
# Which issue does this PR close?
- Closes #8701.
# Rationale for this change
`arrow-avro` already supports writing Avro Object Container Files (OCF)
and framed streaming encodings (e.g. Single-Object Encoding / registry
wire formats). However, many systems exchange **raw Avro binary datum
payloads** (i.e. *only* the Avro record body bytes) while supplying the
schema out-of-band (configuration, RPC contract, topic metadata, etc.).
Without first-class support for unframed datum output, users must
either:
- accept framing overhead that downstream systems don’t expect, or
- re-implement datum encoding themselves.
This PR adds the missing unframed write path and exposes a row-by-row
encoding API to make it easy to embed Avro datums into other transport
protocols.
# What changes are included in this PR?
- Added `AvroBinaryFormat` (unframed) as an `AvroFormat` implementation
to emit **raw Avro record body bytes** (no SOE prefix and no OCF header)
and to explicitly reject container-level compression for this format.
- Added `RecordEncoder::encode_rows` to encode a `RecordBatch` into a
single contiguous buffer while tracking per-row boundaries via appended
offsets.
- Introduced a higher-level `Encoder` + `EncodedRows` API for row-by-row
streaming use cases, providing zero-copy access to individual row slices
(via `Bytes`).
- Updated the writer API to provide `build_encoder` for stream formats
(e.g. SOE) and added row-capacity configuration to better support
incremental/streaming workflows.
- Added the `bytes` crate as a dependency to support efficient buffering
and slicing in the row encoder, and adjusted dev-dependencies to support
the new tests/docs.
# Are these changes tested?
Yes.
This PR adds unit tests that cover:
- single- and multi-column row encoding
- nullable columns
- prefix-based vs. unprefixed row encoding behavior
- empty batch encoding
- appending to existing output buffers and validating offset invariants
# Are there any user-facing changes?
Yes, these changes are additive (no breaking public API changes
expected).
- New writer format support for **unframed Avro binary datum** output
(`AvroBinaryFormat`).
- New row-by-row encoding APIs (`RecordEncoder::encode_rows`, `Encoder`,
`EncodedRows`) to support zero-copy access to per-row encoded bytes.
- New `WriterBuilder` functionality (`build_encoder` + row-capacity
configuration) to enable encoder construction without committing to a
specific `Write` sink.
---------
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>arrow-avro Writer (#9171)1 parent fe126d0 commit fab8e75
File tree
5 files changed
+1485
-126
lines changed- arrow-avro
- benches
- src/writer
5 files changed
+1485
-126
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
79 | | - | |
| 80 | + | |
80 | 81 | | |
81 | | - | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
0 commit comments