ViggoC commented on code in PR #44078:
URL: https://github.com/apache/arrow/pull/44078#discussion_r1759712307


##########
java/vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthViewVector.java:
##########
@@ -1478,7 +1479,7 @@ protected final void handleSafe(int index, int 
dataLength) {
       reallocViewBuffer(Math.max(writePosition, targetCapacity));
     }
 
-    while (index >= getValueCapacity()) {
+    while (index >= getValidityBufferValueCapacity()) {

Review Comment:
   @vibhatha I try to fix testSetSafe, but the logic here makes me confused. 
The writePosition can only be larger than targetCapacity when lastSet < 0. But 
I don't think there is a need for special treatment in this situation. Is there 
a problem if I change it to 
   ```
   final long targetCapacity = roundUpToMultipleOf16((long) index * 
ELEMENT_SIZE + dataLength);
   if (viewBuffer.capacity() < targetCapacity) {
     reallocViewBuffer(targetCapacity);
   }
   ```
   



##########
java/vector/src/test/java/org/apache/arrow/vector/TestVarCharViewVector.java:
##########
@@ -261,6 +261,15 @@ public void testDataBufferBasedAllocationInOtherBuffer() {
     }
   }
 
+  @Test
+  public void testSetSafe() {

Review Comment:
   @vibhatha I wrote a test case for setSafe.



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

Reply via email to