josiahyan commented on a change in pull request #8214: URL: https://github.com/apache/arrow/pull/8214#discussion_r494256371
########## File path: java/vector/src/main/java/org/apache/arrow/vector/BaseFixedWidthVector.java ########## @@ -48,7 +48,8 @@ implements FixedWidthVector, FieldVector, VectorDefinitionSetter { private final int typeWidth; - protected int lastValueCapacity; + protected int lastTargetValueCapacity; Review comment: Sure, I'll change it back! I was a bit worried because of the proximity to actualValueCapacity, but I didn't realized it was used elsewhere and had a larger meaning. ########## File path: java/vector/src/main/java/org/apache/arrow/vector/BaseFixedWidthVector.java ########## @@ -48,7 +48,8 @@ implements FixedWidthVector, FieldVector, VectorDefinitionSetter { private final int typeWidth; - protected int lastValueCapacity; + protected int lastTargetValueCapacity; Review comment: Changed ########## File path: java/vector/src/main/java/org/apache/arrow/vector/BitVector.java ########## @@ -126,7 +126,12 @@ public void setInitialCapacity(int valueCount) { */ @Override public int getValueCapacity() { - return capAtMaxInt(validityBuffer.capacity() * 8); + return actualValueCapacity; + } Review comment: Thanks! Missed that. Removed! ########## File path: java/vector/src/main/java/org/apache/arrow/vector/BitVector.java ########## @@ -126,7 +126,12 @@ public void setInitialCapacity(int valueCount) { */ @Override public int getValueCapacity() { - return capAtMaxInt(validityBuffer.capacity() * 8); + return actualValueCapacity; + } + + @Override + protected void refreshValueCapacity() { + actualValueCapacity = capAtMaxInt(validityBuffer.capacity() * 8); Review comment: Oh yes, that's true. They're two separate (bit)buffers. I'll fix the bug here. ########## File path: java/vector/src/main/java/org/apache/arrow/vector/BitVector.java ########## @@ -126,7 +126,12 @@ public void setInitialCapacity(int valueCount) { */ @Override public int getValueCapacity() { - return capAtMaxInt(validityBuffer.capacity() * 8); + return actualValueCapacity; + } + + @Override + protected void refreshValueCapacity() { + actualValueCapacity = capAtMaxInt(validityBuffer.capacity() * 8); Review comment: Hmm that means that this wasn't picked up on a unit test for some reason; handleSafe threads through the same implementation, looking at it. ########## File path: java/vector/src/main/java/org/apache/arrow/vector/BitVector.java ########## @@ -126,7 +126,12 @@ public void setInitialCapacity(int valueCount) { */ @Override public int getValueCapacity() { - return capAtMaxInt(validityBuffer.capacity() * 8); + return actualValueCapacity; + } + + @Override + protected void refreshValueCapacity() { + actualValueCapacity = capAtMaxInt(validityBuffer.capacity() * 8); Review comment: I guess you need to transfer the buffers or something with an intentionally broken source (if possible) to trigger this. ########## File path: java/vector/src/main/java/org/apache/arrow/vector/BitVector.java ########## @@ -119,13 +119,16 @@ public void setInitialCapacity(int valueCount) { lastValueCapacity = valueCount; } - /** - * Get the current value capacity for the vector. - * - * @return number of elements that vector can hold. - */ @Override - public int getValueCapacity() { + protected void refreshValueCapacity() { Review comment: It isn't, unfortunately. It relies on two private methods, one of which multiplies instead. ########## File path: java/vector/src/main/java/org/apache/arrow/vector/BitVector.java ########## @@ -119,13 +119,16 @@ public void setInitialCapacity(int valueCount) { lastValueCapacity = valueCount; } - /** - * Get the current value capacity for the vector. - * - * @return number of elements that vector can hold. - */ @Override - public int getValueCapacity() { + protected void refreshValueCapacity() { Review comment: Sure, will fix! ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org