You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Andrew Otto (JIRA)" <ji...@apache.org> on 2014/11/05 18:07:34 UTC

[jira] [Updated] (AVRO-1601) Subclasses of Avro generated SpecificRecordBase classes should be considered 'Specific classes'.

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

Andrew Otto updated AVRO-1601:
------------------------------
    Description: 
The createSchema() method of SpecificData class calls getDeclaredField("SCHEMA$") to check if the class is a valid 'Specific' Avro schema class.  It'd be nice if generated classes could be extended so convenience methods could be added without modifying the generated code itself.

E.g. I'd like to convert XML fragments into Avro records, and it would be nice if my the generated class contained the logic to do this, rather than keeping it in some utility class elsewhere.  I'd like to extend the generated Avro schema class to add this functionality, but if I do so I can't call getSchema() on my record objects.  If I try, I get: org.apache.avro.AvroRuntimeException: Not a Specific class: class org.wikimedia.mediawiki.Revision.  This is because the SCHEMA$ field does not exist directly on the subclass, but on the generated (super)class only.

To do this, I think the check for the SCHEMA$ field should look at superclasses as well.  Perhaps FieldUtils.getAllFieldList()[1] would do?

[1] http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/reflect/FieldUtils.html#getAllFieldsList%28java.lang.Class%29

  was:
The createSchema() method of SpecificData class getDeclaredField("SCHEMA$") to check if the class is a valid 'Specific' Avro schema class.  It'd be nice if generated classes could be extended so convenience methods could be added without modifying the generated class.

E.g. I'd like to convert XML fragments into Avro records, and it would be nice if my record abstraction class contained the logic to do this, rather than keeping it in some utility class elsewhere.  I'd like to extend my generated Avro schema class to add this functionality, but if I do so I can't call getSchema() on my record objects.

To do this, I think the check for the SCHEMA$ field should look at superclasses as well.  Perhaps FieldUtils.getAllFieldList()[1] would do?

[1] http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/reflect/FieldUtils.html#getAllFieldsList%28java.lang.Class%29


> Subclasses of Avro generated SpecificRecordBase classes should be considered 'Specific classes'.
> ------------------------------------------------------------------------------------------------
>
>                 Key: AVRO-1601
>                 URL: https://issues.apache.org/jira/browse/AVRO-1601
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>            Reporter: Andrew Otto
>            Priority: Minor
>
> The createSchema() method of SpecificData class calls getDeclaredField("SCHEMA$") to check if the class is a valid 'Specific' Avro schema class.  It'd be nice if generated classes could be extended so convenience methods could be added without modifying the generated code itself.
> E.g. I'd like to convert XML fragments into Avro records, and it would be nice if my the generated class contained the logic to do this, rather than keeping it in some utility class elsewhere.  I'd like to extend the generated Avro schema class to add this functionality, but if I do so I can't call getSchema() on my record objects.  If I try, I get: org.apache.avro.AvroRuntimeException: Not a Specific class: class org.wikimedia.mediawiki.Revision.  This is because the SCHEMA$ field does not exist directly on the subclass, but on the generated (super)class only.
> To do this, I think the check for the SCHEMA$ field should look at superclasses as well.  Perhaps FieldUtils.getAllFieldList()[1] would do?
> [1] http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/reflect/FieldUtils.html#getAllFieldsList%28java.lang.Class%29



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)