[ https://issues.apache.org/jira/browse/AVRO-1268?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13609140#comment-13609140 ]
Doug Cutting commented on AVRO-1268: ------------------------------------ Another way we might implement this is to use the parser. The parser pre-processes the schema into a grammar, allocating symbols that correspond to the elements of the schema. As the resolver runs, the top of the parser's stack contains the symbol corresponding to the current point in the schema being read. So we might add fields to these symbol classes that contain any needed state. To be more specific, we could pass the GenericData instance when the ResolvingDecoder is constructed. We'd then add an ArrayStartAction symbol class with a field for the array's class, replacing the constant Symbol.ARRAY_START. In ResolvingGrammarGenerator#generate() we'd add a call to data.getArrayClass(Schema) and pass this when we construct the ArrayStartAction. In ResolvingDecoder we'd add a method like: {code} Class getArrayClass() { return ((ArrayStartAction)parser.topSymbol()).getArrayClass(); } {code} This could be called by SpecificDatumReader#newArray() to efficiently get the array class while reading. Does that make sense? It would be helpful to have someone more familiar with the parser to advise here. Thiru? > Add java-class, java-key-class and java-element-class support for stringable > types to SpecificData > -------------------------------------------------------------------------------------------------- > > Key: AVRO-1268 > URL: https://issues.apache.org/jira/browse/AVRO-1268 > Project: Avro > Issue Type: Improvement > Components: java > Affects Versions: 1.7.4 > Reporter: Alexandre Normand > Assignee: Alexandre Normand > Priority: Minor > Fix For: 1.7.5 > > Attachments: AVRO-1268-needs-work.patch, AVRO-1268.patch, > AVRO-1268.patch, AVRO-1268-performance.patch, AVRO-1268.sh, > GenericStringsPerf.patch, pseudo.patch, pseudo.patch > > > Stringable types are java classes that can be serialized through strings > (which require a single string constructor and a valid toString() > implementation). ReflectData currently has support from stringable types but > it would be desirable to get this feature with SpecificData. > The work involves changes to the SpecificCompiler (depends on {{@java-class}} > support in AVRO-1267) to generate the specific sources with the proper java > type as well as moving the ReflectDatumReader and ReflectDatumWriter to read > the java-class/java-key-class and java-element-class properties. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira