[ 
https://issues.apache.org/jira/browse/ARROW-2199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16386492#comment-16386492
 ] 

ASF GitHub Bot commented on ARROW-2199:
---------------------------------------

siddharthteotia commented on a change in pull request #1646: ARROW-2199: [JAVA] 
Control the memory allocated for inner vectors in containers.
URL: https://github.com/apache/arrow/pull/1646#discussion_r172282743
 
 

 ##########
 File path: 
java/vector/src/main/java/org/apache/arrow/vector/BaseVariableWidthVector.java
 ##########
 @@ -174,14 +174,14 @@ public void setInitialCapacity(int valueCount) {
    * @param valueCount desired number of elements in the vector
    * @param density average number of bytes per variable width element
    */
+  @Override
   public void setInitialCapacity(int valueCount, double density) {
-    final long size = (long) (valueCount * density);
-    if (size < 1) {
-      throw new IllegalArgumentException("With the provided density and value 
count, potential capacity of the data buffer is 0");
-    }
+    long size = Math.max((long)(valueCount * density), 1L);
 
 Review comment:
   Because it is better to internally set the initial capacity to 1 as opposed 
to throwing exception.
   In our code, we invoke this in a loop dynamically adjusting the density 
value and stepping down the initial capacity because we are working with fix 
memory reservation and limits.
   
   So setInitialCapacity() followed by allocateNew() might fail in the second 
step if not enough memory. So we restart by adjusting the density and stepping 
down the value count. Throwing an exception doesn't help in any case.

----------------------------------------------------------------
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] Follow up fixes for ARROW-2019. Ensure density driven capacity is 
> never less than 1 and propagate density throughout the vector tree
> -------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: ARROW-2199
>                 URL: https://issues.apache.org/jira/browse/ARROW-2199
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: Java - Vectors
>            Reporter: Siddharth Teotia
>            Assignee: Siddharth Teotia
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.9.0
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to