Interesting optimization. Thanks. I have submitted a patch for this as AVRO-841.

~ Nick

On Jun 23, 2011, at 7:20 , Doug Cutting wrote:

> GenericArray permits reuse of elements.  When one repeatedly reads into
> an instance in a loop with, e.g., DatumReader#read(), no new element
> instances need be constructed.  This is because GenericArray does not
> clear its elements as they are removed.  ArrayList always clears
> elements, and this behaviour cannot be overridden.
> 
> Note that, when writing data, any List implementation may be used.  If
> GenericArray is used then reuse is possible, but ArrayList may be used.
> 
> Doug
> 
> On 06/22/2011 03:52 PM, Nick Palmer wrote:
>> For an application I am working on I need GenericData.Array.add(int i, T o) 
>> which is currently not implemented.
>> 
>> For the moment I have implemented this method in my own tree. However, I am 
>> wondering why GenericData.Array is extending AbstractList instead of 
>> extending ArrayList since the methods which are implemented seem to be 
>> reinventing that wheel.
>> 
>> If extending ArrayList is a possibility I would be happy to submit a patch 
>> which does that instead. Otherwise, shall I open a ticket with my existing 
>> patch?
>> 
>> Thanks,
>> ~ Nick
>> 

Reply via email to