rayokota opened a new pull request, #3472: URL: https://github.com/apache/parquet-java/pull/3472
<!-- Thanks for opening a pull request! If you're new to Parquet-Java, information on how to contribute can be found here: https://parquet.apache.org/docs/contribution-guidelines/contributing Please open a GitHub issue for this pull request: https://github.com/apache/parquet-java/issues/new/choose and format pull request title as below: GH-${GITHUB_ISSUE_ID}: ${SUMMARY} or simply use the title below if it is a minor issue: MINOR: ${SUMMARY} --> ### Rationale for this change Fix ByteBuffer handling in VariantUtil and VariantBuilder. ### What changes are included in this PR? - Fix `VariantUtil.getMetadataMap` reading string bytes from the wrong position when the metadata `ByteBuffer` has a non-zero `position()`. Changed `slice(metadata, stringStart + offset)` to `slice(metadata, pos + stringStart + offset`) to match the array-backed branch. - Fix `VariantBuilder.appendBinary` mutating the caller's `ByteBuffer` by using `binary.duplicate()`, consistent with` appendEncodedValue`. ### Are these changes tested? - Added `TestVariantObject.testMetadataWithNonZeroPositionReadOnly`: constructs a metadata `ByteBuffer` with a non-zero position and read-only flag, then verifies ` ImmutableMetadata` (which calls `getMetadataMap`) correctly parses the dictionary. Fails without the fix. - Added `TestVariantScalarBuilder.testBinaryBuilderDoesNotMutateCallerBuffer`: verifies that appendBinary does not change the caller's` ByteBuffer` position or remaining count. ### Are there any user-facing changes? - No <!-- Please uncomment the line below and replace ${GITHUB_ISSUE_ID} with the actual Github issue id. --> Closes #3471 -- 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]
