[ 
https://issues.apache.org/jira/browse/AVRO-2050?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

BELUGA BEHR updated AVRO-2050:
------------------------------
    Attachment: AVRO-2050.2.patch

[~nkollar]

This implementation is essentially an {{ArrayList}}.  The {{ArrayList}} 
overwrites the {{clear}} method because using the default {{AbstractList}} 
implementation requires instantiating an Iterator and then deleting each item 
in the Iterator one at a time.  This is bad performance in terms of constant 
stack manipulation, but also this amounts to draining the array from the head 
of the list.  Draining from the head requires an array copy for each item 
removed to shift down the existing records.  It is much better to override the 
method as {{ArrayList}} has done.  However, I did see some overlap with the 
{{toString}} and {{add}} methods which can be leveraged.  Changed the patch to 
remove the two overrides.

> Clear Array To Allow GC
> -----------------------
>
>                 Key: AVRO-2050
>                 URL: https://issues.apache.org/jira/browse/AVRO-2050
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.7.7, 1.8.2
>            Reporter: BELUGA BEHR
>            Priority: Minor
>         Attachments: AVRO-2050.1.patch, AVRO-2050.2.patch
>
>
> Java's {{ArrayList}} implementation clears all Objects from the internal 
> buffer when the {{clear()}} method is called.  This allows the Objects to be 
> free for GC.  We should do the same in Avro 
> {{org.apache.avro.generic.GenericData}} 
> [ArrayList 
> Source|http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/util/ArrayList.java#ArrayList.clear%28%29]



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to