avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Doug Cutting (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AVRO-648) Use a template library for the SpecificCompiler
Date Wed, 01 Sep 2010 15:55:53 GMT

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

Doug Cutting commented on AVRO-648:
-----------------------------------

Bravo!  This is a great contribution!

A few comments:
 - there are number of whitespace/formatting changes , making the patch harder to read, since
one must scan each of them to see if anything's actually changed.
 - perhaps we could name the set of templates, e.g., org/apache/avro/specific/templates/{$name}/*.vm,
and make the name a parameter of the compiler.  then the existing templates might be named
'classic' or 'simple' and we might then later add, e.g., 'bean' templates that generate accessor
methods?  Or do you intend that as a subsequent contribution?

> Use a template library for the SpecificCompiler
> -----------------------------------------------
>
>                 Key: AVRO-648
>                 URL: https://issues.apache.org/jira/browse/AVRO-648
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>            Reporter: Philip Zeyliger
>            Assignee: Philip Zeyliger
>         Attachments: AVRO-648.patch.txt
>
>
> This JIRA proposes uses a templating library instead of string concatenation for the
SpecificCompiler.
> We've had conversations on the list about customizing the generated code (by adding getters
and setters, adding utility classes for the arrays, adding String-friendly (as opposed to
Utf8) accessors, etc.), but we've been stymied by the fact that the specific compiler is hard-coded
to use one template, and it's hard to experiment with.   Sam Pullara (at http://github.com/spullara/avrocompiler)
has done pretty much this: he forked/subclassed a copy of SpecificCompiler that uses the Mustache
language to generate code.  He's also gone ahead and done some of the customizations.
> In the patch I'm about to post, I've replicated the existing code generation using Velocity.
 We already build Velocity for some of the IPC plugins, and it's an Apache project.  The existing
tests pass, plus I've added tests that check that the generated code is character-for-character
the same, in a handful of cases.  This was actually quite painful, since I had to reproduce
some questionable indentation and trailing whitespace :).  That said, I'm pleased with how
easy it was to incorporate the templates.
> Eventually, I hope we support getters and setters, or perhaps support multiple versions
of templates.  (If someone wants to generate, say, C++ code, the path is now a lot easier
for that, as well.)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message