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

Scott Carey commented on AVRO-853:
----------------------------------

@James 
Yes, I understand what you are talking about.  Partial caching with graph 
traversal would still be a big win.

Ideally immutability with several schema subtypes being referrentially 
transparent would be great (all "int" schemas with no props can be the same 
instance (per classloader) for example, so that the == check triggers more 
often.

It is not safe to assume the calculated hashCode is 0.  We could use MIN_INT 
since it is less likely to occur, but must still assume that that may occur on 
occasion.

Generally speaking with respect to thread-safety:
If hashCode or equals is mutating in _ANY WAY_ it is innapropriate to use the 
objects as a key in a map or in a set -- hashCode and equals must be stable 
during the lifetime of use in a map.  So from that perspective, oddities 
produced by caching the values and mutating the state are user error.  It would 
be nice to remove user error due to mutability from the equation.   


> 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