[
https://issues.apache.org/jira/browse/AVRO-853?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13060916#comment-13060916
]
Scott Carey commented on AVRO-853:
----------------------------------
Both props and aliases are currently mutable. I'd like the whole thing to be
immutable, but that is a fairly significant API change.
The problem with triggering the change of a hash code based on modifying props
or setting fields is that it does not cascade up the reference graph. For
example, if you have a record containing 1 field, that is a record and you
modify the props of the nested record, it can reset its own hash code but won't
reset the outer schema hashCode. Any time we nest a schema in a schema or
field this is a problem.
A truly immutable schema data structure fixes this.
I've been thinking about several ways to change how Schema works to make it
truly immutable -- including props and aliases -- other than setting fields to
handle recursion. This morning I was working on an alternate form of Schema
because I need a "Schema structured" data structure for another project and
require manipulating and composing items associated with schema nodes. That
could be a basis for an immutable Schema data structure.
> 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