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-872) Allow interdependancies across IDL schema imports
Date Wed, 10 Aug 2011 21:35:27 GMT

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

Doug Cutting commented on AVRO-872:
-----------------------------------

There's not much overhead to using IDL for schemas: just use an idl file without any messages:

{code}
@namespace("foo.bar")
protocol MyProtocol {
  import idl "Bar.avdl" ;
  record Foo {
    ...
  }
}
{code}

If you're generating specific code, then Foo will have the same name as if you defined it
in a .avsc file, so no changes to clients should be required.

The only unnecessary part is the protocol name and the fact that an interface is generated
with no methods that you'll never use.  We could change that, e.g., by changing the idl parser
to accept files of the form:


{code}
@namespace("foo.bar")
record Foo {
  import idl "Bar.avdl";
  ...
}
{code}

The return type for the IDL parser could then be either a schema or a protocol, and clients
would need to do different things depending.

> Allow interdependancies across IDL schema imports
> -------------------------------------------------
>
>                 Key: AVRO-872
>                 URL: https://issues.apache.org/jira/browse/AVRO-872
>             Project: Avro
>          Issue Type: Improvement
>            Reporter: Bill Graham
>            Assignee: Doug Cutting
>         Attachments: AVRO-872.patch, AVRO-872.patch, AVRO-872.patch, AVRO-872_4.patch
>
>
> This currently doesn't work because Player depends on Position, but it should:
> {noformat}
> $ cat position.avsc 
> {"type":"enum", "name": "Position", "namespace": "avro.examples.baseball",
>     "symbols": ["P", "C", "B1", "B2", "B3", "SS", "LF", "CF", "RF", "DH"]
> }
> $ cat player.avsc 
> {"type":"record", "name":"Player", "namespace": "avro.examples.baseball",
>   "fields": [
>    {"name": "number", "type": "int"},
>    {"name": "first_name", "type": "string"},
>    {"name": "last_name", "type": "string"},
>    {"name": "position", "type": {"type": "array", "items": "avro.examples.baseball.Position"}
}
>   ]
> }
> $ cat baseball.avdl 
> @namespace("avro.examples.baseball")
> protocol Baseball {
>    import schema "position.avsc";
>    import schema "player.avsc";
> }
> $ java -jar avro-tools-1.5.1.jar idl baseball.avdl baseball.avpr
> {noformat}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message