You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Bill Graham (JIRA)" <ji...@apache.org> on 2011/08/10 06:53:27 UTC

[jira] [Commented] (AVRO-872) Allow interdependancies across IDL schema imports

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

Bill Graham commented on AVRO-872:
----------------------------------

Thanks Doug. I've verified that the idl tool now generates a protocol file. I'm unable to parse this using the Schema.parse(File file) method though. Is that supposed to work, or am I doing it wrong? :)

I've also verified that this now works:
{noformat}
Schema.Parser parser = new Schema.Parser();
parser.parse(new File("position.avsc"));
Schema playerSchema = parser.parse(new File("player.avsc"));
{noformat}

On the email list we've been discussion alternate APIs (http://search-hadoop.com/m/wzbMK11aTL82). Something like this:

{noformat}
public Schema Schema.parse(File[] files);
public Schema Schema.parse(File[] files, Map<Name, Schema> context);
{noformat}

I propose morphing these two approaches to something that could be used like this:
{noformat}
Schema.Parser parser = new Schema.Parser();
parser.parse(new File("position.avsc"));
parser.parse(new File("player.avsc"));
Schema schema = parser.getSchemaByName("Player");

// or alternatively you can pass multiple files to the parse method once
parser.parse(mySchemaFiles);
{noformat}

Thoughts?

> 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
>
>
> 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