[ https://issues.apache.org/jira/browse/ARROW-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16214563#comment-16214563 ]
ASF GitHub Bot commented on ARROW-1474: --------------------------------------- icexelloss commented on a change in pull request #1203: ARROW-1474:[WIP] Java Vector Refactor (Implementation Phase 2) URL: https://github.com/apache/arrow/pull/1203#discussion_r146157662 ########## File path: java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java ########## @@ -129,14 +152,70 @@ public UnionListWriter getWriter() { @Override public void allocateNew() throws OutOfMemoryException { - super.allocateNewSafe(); - bits.allocateNewSafe(); + if (!allocateNewSafe()) { + throw new OutOfMemoryException("Failure while allocating memory"); + } + } + + public boolean allocateNewSafe() { + boolean success = false; + try { + /* allocate validity buffer */ + allocateValidityBuffer(validityAllocationSizeInBytes); + /* allocate offset and data buffer */ + success = super.allocateNewSafe(); + } finally { + if (!success) { + clear(); + return false; + } + } + return true; + } + + private void allocateValidityBuffer(final long size) { Review comment: Ok this is fine. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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 > [JAVA] ValueVector hierarchy (Implementation Phase 2) > ----------------------------------------------------- > > Key: ARROW-1474 > URL: https://issues.apache.org/jira/browse/ARROW-1474 > Project: Apache Arrow > Issue Type: Sub-task > Reporter: Jacques Nadeau > Assignee: Siddharth Teotia > Labels: pull-request-available > -- This message was sent by Atlassian JIRA (v6.4.14#64029)