dkranchii opened a new pull request, #18253:
URL: https://github.com/apache/iceberg/pull/18253

   Closes #17510.
   
   `VariantTestUtil.createArray` carries a TODO asking for a way to size variant
   elements without serializing them. That capability already exists.
   `VariantValue.sizeInBytes()` is contractually the serialized size, and no
   implementation produces bytes to report it: `SerializedValue` returns
   `buffer().remaining()` and its `writeTo` copies exactly that buffer; 
`ValueArray`
   and `ShreddedObject` delegate to `SerializationState.size()`, which is 
arithmetic
   over the recursive sum of element sizes; `PrimitiveWrapper` is a switch over
   constants. `ValueArray` and `ShreddedObject` also share one cached
   `SerializationState` between `size()` and `writeTo()`, so the
   `sizeInBytes()`-then-`writeTo()` sequence in `createArray` builds that state 
once.
   The TODO predates `SerializationState`, so this removes it. `createObject` 
uses the
   same loop and is correct for the same reasons.
   
   Test plan: no new tests, comment-only change. The concern in the issue, that 
an
   embedded `SerializedArray` may not report the size it needs inside a parent, 
is
   already covered by `TestSerializedArray.testArrayOfMixedTypes`, which nests a
   `SerializedArray` in a `createArray` parent and reads every element back.
   `TestShreddedObject.testWriteToDisagreesWithSizeInBytes` separately enforces 
that
   `writeTo` must agree with `sizeInBytes()`.
   
   ---
   **AI Disclosure**
   - Platform/Tool: Cursor
   - Prompt Summary: Investigate issue #17510 on computing variant element 
sizes in VariantTestUtil and implement the change.


-- 
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]

Reply via email to