wombatu-kun opened a new pull request, #18133: URL: https://github.com/apache/iceberg/pull/18133
`ParquetValueWriters.RepeatedWriter.elements(L)` and `RepeatedKeyValueWriter.pairs(M)` are consumed under a contract that has never been written down: `write()` calls them once per value, drains the returned iterator inside that same call, and never retains a reference to it. Implementations are therefore free to return a reused iterator instance instead of allocating one per value. `RepeatedKeyValueWriter` additionally passes each entry to the key and value writers before requesting the next one, so a reused `Map.Entry` is safe too. This adds that contract as javadoc on both abstract methods and pins it down with two tests, so a future change to `write()` that buffers or lazily consumes the iterator fails the build instead of silently corrupting every writer that relies on reuse. Requested by @pvary in https://github.com/apache/iceberg/pull/16791#discussion_r4023472979, where the Flink Parquet array and map writers want to rely on this contract. ### Tests `repeatedWriterConsumesReusedIterator` and `repeatedKeyValueWriterConsumesReusedIteratorAndEntry` write two rows through a writer whose `elements()` / `pairs()` hand out the same iterator instance on every call, and assert the values, the repetition levels reaching the leaf writers, and the identity of the handed-out iterator. Verified the tests are not vacuous by breaking the contract on purpose: with `write()` changed to retain the iterator and drain it on the following call, exactly those two tests fail and the other three in the class still pass. --- **AI Disclosure** - Model: Claude Opus 5 (1M context) - Platform/Tool: Claude Code - Human Oversight: fully reviewed - Prompt Summary: Document the repeated value writer iterator reuse contract in javadoc and add tests that pin it down, as requested in review on PR #16791. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
