cashmand commented on code in PR #3221:
URL: https://github.com/apache/parquet-java/pull/3221#discussion_r2101043579
##########
parquet-variant/src/main/java/org/apache/parquet/variant/VariantBuilder.java:
##########
@@ -96,7 +96,7 @@ public ByteBuffer encodedValue() {
*/
public void appendEncodedValue(ByteBuffer value) {
onAppend();
- int size = value.remaining();
+ int size = VariantUtil.valueSize(value);
Review Comment:
Without this change, we would write to the limit() of `ByteBuffer`, which
could go well past the value being written. The written value would technically
be correct (since a reader would ignore the remaining bytes), but obviously
very inefficient. An alternative to limiting the size here is to do it in the
`getValueBuffer()` method. But depending on what the caller plans to do with
the buffer, the extra bytes might not matter, and we'd be parsing the value
unnecessarily.
--
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]