You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Sharad Agarwal <sh...@yahoo-inc.com> on 2010/07/22 20:40:00 UTC
Avro IDL: Sharing complex types in multiple protocols
I don't find a way to to share complex type in more than one protocol. I
want to do something like:
@namespace ("x.y")
protocol Protocol1 {
record MyRecord {
string name;
}
void message1(MyRecord r);
}
@namespace ("x.y.z")
protocol Protocol2 {
void message2(x.y.MyRecord r);
}
Is there a workaround for this ?
Sharad
Re: Avro IDL: Sharing complex types in multiple protocols
Posted by Doug Cutting <cu...@apache.org>.
On 07/22/2010 11:40 AM, Sharad Agarwal wrote:
> I don't find a way to to share complex type in more than one protocol. I
> want to do something like:
>
> @namespace ("x.y")
> protocol Protocol1 {
> record MyRecord {
> string name;
> }
> void message1(MyRecord r);
> }
>
>
> @namespace ("x.y.z")
> protocol Protocol2 {
> void message2(x.y.MyRecord r);
> }
Yes, Adding support for include to Avro IDL might be the best approach
for this.
https://issues.apache.org/jira/browse/AVRO-495
> Is there a workaround for this ?
You could use m4 or cpp to pre-process IDL files, since those
pre-processors support include. But I think adding include support
directly to Avro IDL would be better.
Doug
Re: Avro IDL: Sharing complex types in multiple protocols
Posted by Jeff Hammerbacher <ha...@cloudera.com>.
Hey Sharad,
I brought up adding protocol inheritance (what we do to solve this problem
in Thrift) to Avro IDL, but Philip felt it was not a good idea:
https://issues.apache.org/jira/browse/AVRO-258?focusedCommentId=12792559&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_12792559
.
A workaround would be to write protocol definition fragments and use a
script of some sort to construct the final protocol file (e.g. manage the
inheritance hierarchy manually). I've seen people do this with Pig scripts
for similar reasons. It's ugly but it works.
Later,
Jeff
On Thu, Jul 22, 2010 at 11:40 AM, Sharad Agarwal <sh...@yahoo-inc.com>wrote:
> I don't find a way to to share complex type in more than one protocol. I
> want to do something like:
>
> @namespace ("x.y")
> protocol Protocol1 {
> record MyRecord {
> string name;
> }
> void message1(MyRecord r);
> }
>
>
> @namespace ("x.y.z")
> protocol Protocol2 {
> void message2(x.y.MyRecord r);
> }
>
> Is there a workaround for this ?
>
> Sharad
>