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

Thiruvalluvan M. G. commented on AVRO-261:
------------------------------------------

bq. does wrapping these not affect performance? Many operations iterate over 
fields or lookup enum symbols. The immutable wrapper adds another method call 
to each such operation. 

One of the heavy users of schema is GenericDatumReader (prior to AVRO-388). On 
my machine the performance of AvroGenericReader went down by 8 - 15%, depending 
on the kind of schema resolution used. Though the impact on GenericDatumReader 
will come down with AVRO-388, other users such as GenericDatumWriter will get 
affected.

I don't see an easy way out. In order to avoid exposing the collections 
directly to the clients, we may add methods like iterator(), get() etc. in the 
Schema itself. But then we'll have the very same problem as the unmodifiable 
wrappers.

With this kind of performance impact I'm reluctant to push this patch.

On the issue of setProp(),  will replacing it with addProp() (meaning one is 
allowed to add new properties to a schema, but not remove or replace existing 
properties) help? This is not quite immutability. But I don't think any code 
will be affected because of additional properties added.

> Allow Schemas to be immutable
> -----------------------------
>
>                 Key: AVRO-261
>                 URL: https://issues.apache.org/jira/browse/AVRO-261
>             Project: Avro
>          Issue Type: New Feature
>          Components: java
>            Reporter: Kevin Oliver
>            Assignee: Thiruvalluvan M. G.
>            Priority: Minor
>         Attachments: AVRO-261.patch
>
>
> It would be nice if there was the ability to have an immutable Schema in 
> java. 
> Without this, it makes sharing schemas risky. Also, with this, we could 
> (lazily) cache the hashCode which is a fairly expensive operation today, 
> especially on something like a record.

-- 
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