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
             Fix For: 1.0.0


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.

Reply via email to