You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "James Baldassari (Commented) (JIRA)" <ji...@apache.org> on 2011/12/01 16:34:40 UTC

[jira] [Commented] (AVRO-964) Provide clone() method for generated avro-specific objects

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

James Baldassari commented on AVRO-964:
---------------------------------------

OK, then it sounds like either the serialization/deserialization method or the Builder method will work for you in the short term.  If you want to work on a copy/deepClone method for the generated code, check out the {{record.vm}} Velocity template under {{lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/}}.  That would definitely need to be updated, and I would imagine that you would also want to add some code to {{org.apache.avro.specific.SpecificRecordBase}} and possibly {{org.apache.avro.SpecificData}}.
                
> Provide clone() method for generated avro-specific objects
> ----------------------------------------------------------
>
>                 Key: AVRO-964
>                 URL: https://issues.apache.org/jira/browse/AVRO-964
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.7.0
>            Reporter: Vyacheslav Zholudev
>
> It would be great to provide a generated clone() method for avro-specific objects like it is done for equals(), toString() and hashCode() methods.
> Due to object re-usage in Hadoop, it is often necessary to clone objects because they have to be processed all together after e.g. Reducer input has been read. 
> Currently I see two ad-hoc options to deal with it:
> 1) Create potentially lots of tedious code to clone objects manually. This method is error-prone, since it's easy to forget cloning of some fields after schema evolution
> 2) Use DatumWriter and DatumReader to serialize/deserialize objects. This method works extremely slow (in my experiments 30-40 times slower than method #1.
> So neither of methods is sufficiently good, on the other hand adding a generated clone() method should be not that complicated.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira