sunchao commented on a change in pull request #11709:
URL: https://github.com/apache/arrow/pull/11709#discussion_r766127414



##########
File path: 
java/vector/src/main/java/org/apache/arrow/vector/BitVectorHelper.java
##########
@@ -329,7 +329,8 @@ public static ArrowBuf loadValidityBuffer(final 
ArrowFieldNode fieldNode,
     final int valueCount = fieldNode.getLength();
     ArrowBuf newBuffer = null;
     /* either all NULLs or all non-NULLs */
-    if (fieldNode.getNullCount() == 0 || fieldNode.getNullCount() == 
valueCount) {
+    if (sourceValidityBuffer == null && (fieldNode.getNullCount() == 0 ||

Review comment:
       OK, found another issue with IPC between C++ and Java. In this case even 
though the source validity buffer is null from the C++ side, when deserializing 
it from the IPC `RecordBatch`, it is just a slice derived from the original 
message body (the IPC format seems to require validity buffer to always be 
present, even if all values are not-null in the Arrow array). Therefore, it 
won't be null or having a null memory address. 
   
   To fix, I changed the check to be:
   
   ```
   sourceValidityBuffer == null || sourceValidityBuffer.capacity() == 0;
   ```
   
   The latter indicates that the buffer is empty.




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