You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "rustyconover (via GitHub)" <gi...@apache.org> on 2026/10/16 15:04:38 UTC
[PR] feat(ipc): Add ArrowIpcWriterSetMessageMetadata [arrow-nanoarrow]
rustyconover opened a new pull request, #967:
URL: https://github.com/apache/arrow-nanoarrow/pull/967
`ArrowIpcEncoderSetMessageMetadata()` (#924, narrowed in #937) attaches `Message::custom_metadata` to the next message an encoder encodes. An `ArrowIpcWriter` keeps its encoder private, though, so a caller using the writer has no way to attach metadata to the RecordBatch messages it writes. The only option is to drop down to the encoder and redo the writer's framing, footer bookkeeping and dictionary handling by hand.
This PR adds `ArrowIpcWriterSetMessageMetadata(writer, metadata, error)`. The writer holds the metadata and attaches it to the next RecordBatch message written by `ArrowIpcWriterWriteArrayView()` or `ArrowIpcWriterWriteArrayStream()`. The metadata applies to that one message. Passing `NULL` clears metadata that has been set but not yet written. Like the encoder function, it takes ownership of the buffer.
The metadata is held by the writer rather than set on the encoder right away. Setting it on the encoder would attach it to whichever message is encoded next, and that can be a DictionaryBatch written ahead of the batch. This happens both with an explicit `ArrowIpcWriterWriteDictionaryBatch()` call and inside `ArrowIpcWriterWriteArrayStream()`. RecordBatch-level metadata belongs on the RecordBatch, so the writer passes it to the encoder just before encoding that batch.
Things worth a look in review:
- With `WriteArrayStream()` the metadata lands on the first RecordBatch only. Per-batch metadata over a stream would need a callback or a per-array side channel, which seemed out of scope. The batch-at-a-time pattern is `SetMessageMetadata()` + `WriteArrayView()`.
- #928 makes encoder-level metadata apply to DictionaryBatch messages too. The two compose: this PR never sets encoder metadata until right before the RecordBatch is encoded. They touch neighbouring code in `writer.c`, so whichever lands second will need a small rebase. I can do that.
Motivation: I'm moving the IPC layer of a DuckDB extension from Arrow C++ to nanoarrow. Its RPC protocol carries per-batch state in RecordBatch `custom_metadata` (what Arrow C++ writes for `RecordBatchWriter::WriteRecordBatch(batch, custom_metadata)`), and this was the one thing the writer couldn't express.
Tests:
- `MessageMetadataAttachesToNextRecordBatch` sets metadata, writes a DictionaryBatch and then a RecordBatch, and checks that only the RecordBatch carries it. It also checks that the following batch doesn't inherit the metadata, and that set-then-cleared metadata is never written.
- `MessageMetadataWithArrayStream` covers `WriteArrayStream()` writing its own dictionaries.
ctest passes locally (macOS arm64, Debug, ZSTD/LZ4, 390 tests). The IPC writer, encoder and files tests are clean under ASan/UBSan.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(ipc): Add ArrowIpcWriterSetMessageMetadata [arrow-nanoarrow]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #967:
URL: https://github.com/apache/arrow-nanoarrow/pull/967#issuecomment-6218508063
## [Codecov](https://app.codecov.io/gh/apache/arrow-nanoarrow/pull/967?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `92.85714%` with `1 line` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 78.25%. Comparing base ([`e5f3d0a`](https://app.codecov.io/gh/apache/arrow-nanoarrow/commit/e5f3d0a55d5576386359835f7bf052f983d1161f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`aafc9b0`](https://app.codecov.io/gh/apache/arrow-nanoarrow/commit/aafc9b08b23717ac58e79af1da3d46d6b170fb77?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/arrow-nanoarrow/pull/967?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [src/nanoarrow/ipc/writer.c](https://app.codecov.io/gh/apache/arrow-nanoarrow/pull/967?src=pr&el=tree&filepath=src%2Fnanoarrow%2Fipc%2Fwriter.c&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL25hbm9hcnJvdy9pcGMvd3JpdGVyLmM=) | 92.85% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/arrow-nanoarrow/pull/967?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #967 +/- ##
==========================================
+ Coverage 78.24% 78.25% +0.01%
==========================================
Files 106 106
Lines 16901 16915 +14
Branches 2012 2015 +3
==========================================
+ Hits 13224 13237 +13
Misses 2435 2435
- Partials 1242 1243 +1
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/arrow-nanoarrow/pull/967?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Add ArrowIpcWriterSetMessageMetadata [arrow-nanoarrow]
Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot merged PR #967:
URL: https://github.com/apache/arrow-nanoarrow/pull/967
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org