You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/12/03 00:12:28 UTC

[GitHub] [arrow] sunchao commented on a change in pull request #11709: ARROW-14718: [Java] loadValidityBuffer should avoid allocating memory when input is not null and there are only null or non-null values

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



##########
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:
       It turned out this is because the ORC adapter wraps null validity buffer from native side with `OrcMemoryJniWrapper`, which then gets converted into `ArrowBuf` with `memoryAddress` equals to 0 (i.e., it wraps a null buffer).
   
   With the change in this PR, the Java side will think the `ArrowBuf` is valid and thus will skip allocating new buffer. However it is actually invalid and thus will cause a series of issues.
   
   I added an additional check of the `ArrowBuf`'s memory address, to make sure it is indeed a null validity buffer.
   
   




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