You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "hutiefang76 (via GitHub)" <gi...@apache.org> on 2026/09/10 08:09:29 UTC

[PR] GH-812: Fix appending to an empty UnionVector [arrow-java]

hutiefang76 opened a new pull request, #1292:
URL: https://github.com/apache/arrow-java/pull/1292

   ## What's Changed
   
   Appending to a newly created `UnionVector` repeatedly reallocates its type buffer until allocation fails: its value capacity remains zero until it has child vectors. Check the type buffer capacity at this stage, since the existing append loop creates and expands the child vectors afterward.
   
   The regression appends two floats to an empty union with a bounded allocator. It fails before the change with an allocation error and passes afterward. All 32 `TestVectorAppender` tests pass with both the Netty and Unsafe allocators on JDK 21. Checkstyle and Spotless also pass.
   
   Closes #812.
   
   Validation (JDK 21):
   
   ```sh
   mvn -B -pl vector -am test -Dtest=TestVectorAppender -Dsurefire.failIfNoSpecifiedTests=false
   mvn -B -pl vector spotless:check
   ```
   
   Developed with AI assistance; the regression was verified to fail before the fix and pass afterward.
   


-- 
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] GH-812: Fix appending to an empty UnionVector [arrow-java]

Posted by "jbonofre (via GitHub)" <gi...@apache.org>.
jbonofre merged PR #1292:
URL: https://github.com/apache/arrow-java/pull/1292


-- 
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] GH-812: Fix appending to an empty UnionVector [arrow-java]

Posted by "hutiefang76 (via GitHub)" <gi...@apache.org>.
hutiefang76 commented on code in PR #1292:
URL: https://github.com/apache/arrow-java/pull/1292#discussion_r4007462877


##########
vector/src/main/java/org/apache/arrow/vector/util/VectorAppender.java:
##########
@@ -601,8 +601,8 @@ public ValueVector visit(UnionVector deltaVector, Void value) {
     UnionVector targetUnionVector = (UnionVector) targetVector;
     int newValueCount = targetVector.getValueCount() + deltaVector.getValueCount();
 
-    // make sure there is enough capacity
-    while (targetUnionVector.getValueCapacity() < newValueCount) {
+    // Child vectors are created and expanded below; an empty union has zero value capacity.

Review Comment:
   Removed in ea411ff. This revision only removes the comment; the implementation and regression test are unchanged.



-- 
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] GH-812: Fix appending to an empty UnionVector [arrow-java]

Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on code in PR #1292:
URL: https://github.com/apache/arrow-java/pull/1292#discussion_r4002170784


##########
vector/src/main/java/org/apache/arrow/vector/util/VectorAppender.java:
##########
@@ -601,8 +601,8 @@ public ValueVector visit(UnionVector deltaVector, Void value) {
     UnionVector targetUnionVector = (UnionVector) targetVector;
     int newValueCount = targetVector.getValueCount() + deltaVector.getValueCount();
 
-    // make sure there is enough capacity
-    while (targetUnionVector.getValueCapacity() < newValueCount) {
+    // Child vectors are created and expanded below; an empty union has zero value capacity.

Review Comment:
   ```suggestion
   ```



-- 
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] GH-812: Fix appending to an empty UnionVector [arrow-java]

Posted by "hutiefang76 (via GitHub)" <gi...@apache.org>.
hutiefang76 commented on PR #1292:
URL: https://github.com/apache/arrow-java/pull/1292#issuecomment-5644938405

   The PR-format job failed because the required category label is missing. This is a bug fix for #812 with no breaking API change. Could a maintainer add `bug-fix`? My account does not have permission to add repository labels.
   


-- 
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] GH-812: Fix appending to an empty UnionVector [arrow-java]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #1292:
URL: https://github.com/apache/arrow-java/pull/1292#issuecomment-5615828341

   
   <!-- label_helper_comment -->
   Thank you for opening a pull request!
   
   Please label the PR with one or more of:
   
   - bug-fix
   - chore
   - dependencies
   - documentation
   - enhancement
   
   Also, add the 'breaking-change' label if appropriate.
   
   See [CONTRIBUTING.md](https://github.com/apache/arrow-java/blob/main/CONTRIBUTING.md) for 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