You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "goutamadwant (via GitHub)" <gi...@apache.org> on 2026/06/18 01:47:57 UTC

[PR] GH-1190: Reserve view slots for empty view vector values [arrow-java]

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

   ## What's Changed
   
   Fixes `BaseVariableWidthViewVector.handleSafe` so `setSafe` reserves a full 16-byte view slot for the target index even when the value length is zero.
   
   Adds coverage for empty values written through the first view-buffer boundary for both `ViewVarCharVector` and `ViewVarBinaryVector`.
   
   ## Tests
   
   - `mvn -pl vector -am -Dtest=TestVariableWidthViewVector#testSetSafeEmptyValueAtViewBufferBoundary -Dsurefire.failIfNoSpecifiedTests=false test`
   - `mvn -pl vector -am -Dtest=TestVariableWidthViewVector -Dsurefire.failIfNoSpecifiedTests=false test`
   
   Closes #1190.
   


-- 
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-1190: Reserve view slots for empty view vector values [arrow-java]

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

   @parthchandra Rebased this PR on latest main and pushed the update... also ran Spotless; the only formatting change was wrapping the long comment in BaseVariableWidthViewVector.java.
   
   checked locally with below runs : 
   
   - mvn --batch-mode -pl vector spotless:check
   - mvn --batch-mode -pl vector -am -Dtest=TestVariableWidthViewVector -Dsurefire.failIfNoSpecifiedTests=false test
   
   The focused vector test passed under both netty and unsafe runs. Let me know. thanks! 


-- 
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-1190: Reserve view slots for empty view vector values [arrow-java]

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


##########
vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthViewVector.java:
##########
@@ -1405,7 +1405,8 @@ public final int getTotalValueLengthUpToIndex(int index) {
   }
 
   protected final void handleSafe(int index, int dataLength) {
-    final long targetCapacity = roundUpToMultipleOf16((long) index * ELEMENT_SIZE + dataLength);
+    // The view buffer stores one fixed-width view per value; payload bytes are allocated separately.
+    final long targetCapacity = roundUpToMultipleOf16(((long) index + 1) * ELEMENT_SIZE);

Review Comment:
   Correct. Reserves the full slot regardless of payload; `((long) index + 1)` avoids overflow. `roundUpToMultipleOf16` is a no-op here but fine to keep.



##########
vector/src/test/java/org/apache/arrow/vector/TestVariableWidthViewVector.java:
##########
@@ -540,6 +540,26 @@ public void testSizeOfViewBufferElements() {
     }
   }
 
+  @ParameterizedTest
+  @MethodSource({"vectorCreatorProvider"})
+  public void testSetSafeEmptyValueAtViewBufferBoundary(

Review Comment:
   Only covers the empty-value path. `setNull` and `fillEmpties`/`setValueCount` reach the same `handleSafe(index, 0)`. Suggest adding tests for those.
   
   ## Suggested tests (imports already present)
   
   ### setValueCount trailing gap (silent trigger, no empty string written)
   ```java
   @ParameterizedTest
   @MethodSource({"vectorCreatorProvider"})
   public void testSetValueCountFillsEmptiesAtViewBufferBoundary(
       Function<BufferAllocator, BaseVariableWidthViewVector> vectorCreator) {
     try (final BaseVariableWidthViewVector vector = vectorCreator.apply(allocator)) {
       vector.allocateNew();
       final int valueCapacity = vector.getValueCapacity();
       vector.setSafe(valueCapacity - 1, "x".getBytes(StandardCharsets.UTF_8));
       // Leaves index valueCapacity unset: fillEmpties -> handleSafe(_, 0) on a full buffer.
       vector.setValueCount(valueCapacity + 1);
       assertTrue(vector.getValueCapacity() > valueCapacity);
       assertTrue(vector.isNull(valueCapacity));
     }
   }
   ```
   
   ### setNull at the boundary
   ```java
   @ParameterizedTest
   @MethodSource({"vectorCreatorProvider"})
   public void testSetNullAtViewBufferBoundary(
       Function<BufferAllocator, BaseVariableWidthViewVector> vectorCreator) {
     try (final BaseVariableWidthViewVector vector = vectorCreator.apply(allocator)) {
       vector.allocateNew();
       final int valueCapacity = vector.getValueCapacity();
       for (int i = 0; i <= valueCapacity; i++) {
         vector.setNull(i);
       }
       vector.setValueCount(valueCapacity + 1);
       assertTrue(vector.getValueCapacity() > valueCapacity);
       assertTrue(vector.isNull(valueCapacity));
     }
   }
   ```



##########
vector/src/test/java/org/apache/arrow/vector/TestVariableWidthViewVector.java:
##########
@@ -540,6 +540,26 @@ public void testSizeOfViewBufferElements() {
     }
   }
 
+  @ParameterizedTest
+  @MethodSource({"vectorCreatorProvider"})
+  public void testSetSafeEmptyValueAtViewBufferBoundary(

Review Comment:
   Only covers the empty-value path. `setNull` and `fillEmpties`/`setValueCount` reach the same `handleSafe(index, 0)`. Suggest adding tests for those.
   
   ### setValueCount trailing gap (silent trigger, no empty string written)
   ```java
   @ParameterizedTest
   @MethodSource({"vectorCreatorProvider"})
   public void testSetValueCountFillsEmptiesAtViewBufferBoundary(
       Function<BufferAllocator, BaseVariableWidthViewVector> vectorCreator) {
     try (final BaseVariableWidthViewVector vector = vectorCreator.apply(allocator)) {
       vector.allocateNew();
       final int valueCapacity = vector.getValueCapacity();
       vector.setSafe(valueCapacity - 1, "x".getBytes(StandardCharsets.UTF_8));
       // Leaves index valueCapacity unset: fillEmpties -> handleSafe(_, 0) on a full buffer.
       vector.setValueCount(valueCapacity + 1);
       assertTrue(vector.getValueCapacity() > valueCapacity);
       assertTrue(vector.isNull(valueCapacity));
     }
   }
   ```
   
   ### setNull at the boundary
   ```java
   @ParameterizedTest
   @MethodSource({"vectorCreatorProvider"})
   public void testSetNullAtViewBufferBoundary(
       Function<BufferAllocator, BaseVariableWidthViewVector> vectorCreator) {
     try (final BaseVariableWidthViewVector vector = vectorCreator.apply(allocator)) {
       vector.allocateNew();
       final int valueCapacity = vector.getValueCapacity();
       for (int i = 0; i <= valueCapacity; i++) {
         vector.setNull(i);
       }
       vector.setValueCount(valueCapacity + 1);
       assertTrue(vector.getValueCapacity() > valueCapacity);
       assertTrue(vector.isNull(valueCapacity));
     }
   }
   ```



-- 
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-1190: Reserve view slots for empty view vector values [arrow-java]

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

   @goutamadwant could you rebase on main and also run spotless? 


-- 
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-1190: Reserve view slots for empty view vector values [arrow-java]

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

   @lidavidm @wgtmac @laurentgo @jbonofre Can you please take a look? 


-- 
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-1190: Reserve view slots for empty view vector values [arrow-java]

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


##########
vector/src/test/java/org/apache/arrow/vector/TestVariableWidthViewVector.java:
##########
@@ -540,6 +540,26 @@ public void testSizeOfViewBufferElements() {
     }
   }
 
+  @ParameterizedTest
+  @MethodSource({"vectorCreatorProvider"})
+  public void testSetSafeEmptyValueAtViewBufferBoundary(

Review Comment:
   @mbutrovich added coverage for both additional paths: `setNull` and `setValueCount`/`fillEmpties` at the view-buffer boundary. The production fix is unchanged and his just closes the missing regression coverage. Let me know. thanks! 



-- 
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-1190: Reserve view slots for empty view vector values [arrow-java]

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


-- 
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-1190: Reserve view slots for empty view vector values [arrow-java]

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

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


Re: [PR] GH-1190: Reserve view slots for empty view vector values [arrow-java]

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

   @lidavidm @wgtmac @laurentgo @jbonofre  is anyone able to look into the ci failures? They are unrelated to this PR as far as I can see. 


-- 
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-1190: Reserve view slots for empty view vector values [arrow-java]

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

   > but CI is not passing
   
   Looks like a rebase and running spotless will fix the CI issues. 


-- 
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-1190: Reserve view slots for empty view vector values [arrow-java]

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

   Please rebase


-- 
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-1190: Reserve view slots for empty view vector values [arrow-java]

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

   > Please rebase
   
   @lidavidm rebased onto the latest main and pushed the updated commits. thanks! 


-- 
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-1190: Reserve view slots for empty view vector values [arrow-java]

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


##########
vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthViewVector.java:
##########
@@ -1405,7 +1405,8 @@ public final int getTotalValueLengthUpToIndex(int index) {
   }
 
   protected final void handleSafe(int index, int dataLength) {
-    final long targetCapacity = roundUpToMultipleOf16((long) index * ELEMENT_SIZE + dataLength);
+    // The view buffer stores one fixed-width view per value; payload bytes are allocated separately.
+    final long targetCapacity = roundUpToMultipleOf16(((long) index + 1) * ELEMENT_SIZE);

Review Comment:
   Thanks for reviewing @mbutrovich . I kept this code path unchanged since it reserves the full view slot regardless of payload size and the cast keeps the sizing expression safe before the multiplication. Let me know if there any other thoughts. 



-- 
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-1190: Reserve view slots for empty view vector values [arrow-java]

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

   @mbutrovich addressed your comments. let me know if you have more suggestions. thanks! 


-- 
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-1190: Reserve view slots for empty view vector values [arrow-java]

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

   @parthchandra  any further change needed from my side for this PR ?


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