You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Doug Cutting (JIRA)" <ji...@apache.org> on 2009/08/28 00:27:59 UTC

[jira] Resolved: (AVRO-63) Optimize #hashCode() and #equals() for Protocol and Schema

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

Doug Cutting resolved AVRO-63.
------------------------------

    Resolution: Won't Fix

This optimization is premature.

> Optimize #hashCode() and #equals() for Protocol and Schema
> ----------------------------------------------------------
>
>                 Key: AVRO-63
>                 URL: https://issues.apache.org/jira/browse/AVRO-63
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>            Reporter: Doug Cutting
>
> It's often useful to cache things derived from a Schema or Protocol in a WeakHashMap.  Each cache lookup involves at least one call to #equals() and #hashCode() on the Schema or Protocol.  But the Schema#hashCode() is expensive, since it must walk the entire schema, allocating objects to detect circular schemas.  It would be better if Schema cached its hash code in a field.  This can also be used optimize Schema#equals(): if two Schema's do not have the same hashCode then they cannot be equal.  With these optimizations, the only slow case would be a cache lookup of an equal but not identical Schema.  Perhaps even this can be optimized by caching its MD5 and assuming that, if the MD5 does not match, schemas are not equal.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.