You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Michael Pigott (JIRA)" <ji...@apache.org> on 2014/11/11 04:54:33 UTC
[jira] [Commented] (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:comment-tabpanel&focusedCommentId=14205906#comment-14205906 ]
Michael Pigott commented on AVRO-1601:
--------------------------------------
Hi Andrew,
I actually have a patch for AVRO-457, which will generate an Avro schema from an XML Schema counterpart, and convert XML documents to Avro documents and back. It unfortunately hasn't gotten much traction, but feel free to check it out. It's completely independent of the rest of the Avro code, so you should be able to incorporate it in your own project. Or just pull it from my GitHub repository, https://github.com/mikepigott/xml-to-avro . Feedback is appreciated!
Mike
> 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)