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

Doug Cutting commented on AVRO-853:
-----------------------------------

Another approach to your performance issue might be to use IdentityHashMap.

Note that Schema properties can be added at any time, so all schemas are 
mutable from that perspective, and the hashcode incorporates the properties.  
So addProp() should also invalidate the cache.

Instead of having cache logic in many schema subclasses, perhaps the base 
implementation can be in terms of a new calculateHashcode() method that each of 
the subclasses implements instead of hashCode.  Then the cache need only be 
implemented on the base Schema class.


> Cache hash codes in Schema and Field
> ------------------------------------
>
>                 Key: AVRO-853
>                 URL: https://issues.apache.org/jira/browse/AVRO-853
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.5.1
>            Reporter: Douglas Kaminsky
>         Attachments: AVRO-853.patch
>
>
> We are experiencing a serious performance degradation when trying to 
> store/retrieve fields and schemas in hash-based data structures (eg. 
> HashMap). Since all fields and schemas are immutable (with the exception of 
> RecordSchema allowing deferred setting of Fields) it makes sense to cache the 
> hash code on the object instead of recalculating every time the hashCode 
> method gets called. 
> (Are there other mutable Schema sub-types that I'm not thinking about?)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to