liyafan82 commented on a change in pull request #7290: URL: https://github.com/apache/arrow/pull/7290#discussion_r439336805
########## File path: java/vector/src/main/codegen/templates/UnionVector.java ########## @@ -493,6 +576,19 @@ public void splitAndTransfer(int startIndex, int length) { Preconditions.checkArgument(startIndex >= 0 && length >= 0 && startIndex + length <= valueCount, "Invalid parameters startIndex: %s, length: %s for valueCount: %s", startIndex, length, valueCount); to.clear(); + // transfer validity buffer + while (to.getValidityBufferValueCapacity() < length) { + to.reallocValidityBuffer(); + } + for (int i = 0; i < length; i++) { + int validity = BitVectorHelper.get(validityBuffer, startIndex + i); + if (validity == 0) { + BitVectorHelper.unsetBit(to.validityBuffer, i); + } else { + BitVectorHelper.setBit(to.validityBuffer, i); + } Review comment: nit: Maybe we can use ``` setValidityBit(ArrowBuf validityBuffer, int index, int value) ``` here to make the code more concise? ---------------------------------------------------------------- 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