Thanks Sidd. Actually, I was looking at the code in base classes for Vector 
implementation, and it does take care of reallocation itself (which I was 
thinking of doing explicitly in the code). Although it uses "reAlloc" which 
allocates double the current size,  for me it works - as I plan to start with 
moderate initial capacity for the vectors. 


-----Original Message-----
From: Siddharth Teotia [] 
Sent: Friday, February 23, 2018 12:14 PM
Subject: Re: Allocating additional memory to the Java Vector objects

Hi Atul,

Currently there is no way for doing this. The only exposed method of expanding 
the vector buffer is reAlloc() and it allocates a new buffer of double the 
original capacity and copies the old contents into the new buffer.


On Fri, Feb 23, 2018 at 12:06 PM, Atul Dambalkar <
> wrote:

> Hi,
> I am creating IntVector in Java as follows - IntVector intVector = 
> (IntVector) vectorSchemaRoot.getVector(name); 
> intVector.setInitialCapacity(100);
> intVector.allocateNew();
> Is there a way that I can allocate additional capacity to the same 
> IntVector object by a defined number? Let's say something like - 
> intVector.allocateAdditional(100), which would only add more capacity 
> to the existing buffer without impacting the existing buffer and data.
> There is an API intVector.reAlloc, but it simply doubles the current 
> allocated memory and not what I intend.
> Thanks for your inputs,
> -Atul

Reply via email to