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

Timothy Farkas commented on DRILL-6234:
---------------------------------------

[~paul-rogers] The motivation for this was to make handling cases where you 
don't know the amount of data that will go into the vector upfront a little 
simpler. Such a case is a BatchHolder in a hash table where it is desirable to 
grow the vectors as you get more data instead preallocating a large chunk of 
memory that could go unused. You are right, an index out of bound exception 
does occur when setting more elements than there are in the vector, however, I 
assumed things would behave as they do with the FixedWidth vectors. For example 
Uint4Vector resizes the array to fit valueCount elements when setValueCount is 
called even if setValueCount. So if we can make the behavior consistent without 
any negative side effects, then why not do it?

> VarCharVector setValueCount can throw IndexOutOfBoundsException
> ---------------------------------------------------------------
>
>                 Key: DRILL-6234
>                 URL: https://issues.apache.org/jira/browse/DRILL-6234
>             Project: Apache Drill
>          Issue Type: Improvement
>            Reporter: Timothy Farkas
>            Assignee: Timothy Farkas
>            Priority: Major
>
> Doing the following will throw an Index out of bounds exception.
> {code}
>       final VarCharVector vector = new VarCharVector(field, allocator);
>       vector.allocateNew();
>       vector.getMutator().setValueCount(100);
> {code}
> The expected behavior is to resize the array appropriately. If an index is 
> uninitialized you should not call get for that index.



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

Reply via email to