You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Casadio Phaedra <Ph...@datamanagementpa.it> on 2014/02/06 10:14:49 UTC

Hi to all, little problem when compiling avcr

Hi to all, my name is Phaedra, i'm working in a company in Italy specialized in data management for public/private libraries.
We are evaluating Avro for our rpc needs, for now Avro mapping seems to be really better than thrift or protobuf one.

BUT, I'm stuck while compiling an avdl file to avcr file and then compiling to beans.

IDL file example:

@namespace("avro.bean")
protocol MyProtocol {

  record MyBean {
    union { null, string } cd;
    union { null, string } ds;
  }

  MyBean getMyBean(array<string> array);
}

Morph in to this:

{
  "protocol" : "MyProtocol",
  "namespace" : "avro.bean",
  "types" : [ {
    "type" : "record",
    "name" : "MyBean",
    "fields" : [ {
      "name" : "cd",
      "type" : [ "null", "string" ]
    }, {
      "name" : "ds",
      "type" : [ "null", "string" ]
    } ]
  } ],
  "messages" : {
    "getMyBean" : {
      "request" : [ {
        "name" : "array",
        "type" : {
          "type" : "array",
          "items" : "string"
        }
      } ],
      "response" : "MyBean"
    }
  }
}

For now, it's going all as expected.
BUT when I'm going to compile the schema:

Input files to compile:
  avro\idl.avpr

Exception in thread "main" org.apache.avro.SchemaParseException: No type: {"protocol":"MyProtocol","namespace":"avro.bea
n","types":[{"type":"record","name":"MyBean","fields":[{"name":"cd","type":["null","string"]},{"name":"ds","type":["null
","string"]}]}],"messages":{"getMyBean":{"request":[{"name":"array","type":{"type":"array","items":"string"}}],"response
":"MyBean"}}}
        at org.apache.avro.Schema.getRequiredText(Schema.java:1221)
        at org.apache.avro.Schema.parse(Schema.java:1082)
        at org.apache.avro.Schema$Parser.parse(Schema.java:953)
        at org.apache.avro.Schema$Parser.parse(Schema.java:922)
        at org.apache.avro.tool.SpecificCompilerTool.run(SpecificCompilerTool.java:73)
        at org.apache.avro.tool.Main.run(Main.java:84)
        at org.apache.avro.tool.Main.main(Main.java:73)

Argh, no way to understand what's happening in the compiling process.

Can someone help me out this one???

Thanks, Phaedra.


R: Hi to all, little problem when compiling avcr

Posted by Casadio Phaedra <Ph...@datamanagementpa.it>.
Thanks very much, but, if I can, why different command line param for both? Cannot find by “protocol” keyword?

Phaedra

Da: Christophe Taton [mailto:taton@wibidata.com]
Inviato: giovedì 6 febbraio 2014 17:08
A: user@avro.apache.org
Oggetto: Re: Hi to all, little problem when compiling avcr

Hi,

It looks like you are invoking the Avro compiler for a schema instead of for a protocol.
If you are running a command like this one:
    $ java -jar path/to/avro-tools.jar compile schema path/to/idl.avpr path/to/generated

Then you should try:
    $ java -jar path/to/avro-tools.jar compile protocol path/to/idl.avpr path/to/generated

C.

On Thu, Feb 6, 2014 at 1:14 AM, Casadio Phaedra <Ph...@datamanagementpa.it>> wrote:
Hi to all, my name is Phaedra, i’m working in a company in Italy specialized in data management for public/private libraries.
We are evaluating Avro for our rpc needs, for now Avro mapping seems to be really better than thrift or protobuf one.

BUT, I’m stuck while compiling an avdl file to avcr file and then compiling to beans.

IDL file example:

@namespace("avro.bean")
protocol MyProtocol {

  record MyBean {
    union { null, string } cd;
    union { null, string } ds;
  }

  MyBean getMyBean(array<string> array);
}

Morph in to this:

{
  "protocol" : "MyProtocol",
  "namespace" : "avro.bean",
  "types" : [ {
    "type" : "record",
    "name" : "MyBean",
    "fields" : [ {
      "name" : "cd",
      "type" : [ "null", "string" ]
    }, {
      "name" : "ds",
      "type" : [ "null", "string" ]
    } ]
  } ],
  "messages" : {
    "getMyBean" : {
      "request" : [ {
        "name" : "array",
        "type" : {
          "type" : "array",
          "items" : "string"
        }
      } ],
      "response" : "MyBean"
    }
  }
}

For now, it’s going all as expected.
BUT when I’m going to compile the schema:

Input files to compile:
  avro\idl.avpr

Exception in thread "main" org.apache.avro.SchemaParseException: No type: {"protocol":"MyProtocol","namespace":"avro.bea
n","types":[{"type":"record","name":"MyBean","fields":[{"name":"cd","type":["null","string"]},{"name":"ds","type":["null
","string"]}]}],"messages":{"getMyBean":{"request":[{"name":"array","type":{"type":"array","items":"string"}}],"response
":"MyBean"}}}
        at org.apache.avro.Schema.getRequiredText(Schema.java:1221)
        at org.apache.avro.Schema.parse(Schema.java:1082)
        at org.apache.avro.Schema$Parser.parse(Schema.java:953)
        at org.apache.avro.Schema$Parser.parse(Schema.java:922)
        at org.apache.avro.tool.SpecificCompilerTool.run(SpecificCompilerTool.java:73)
        at org.apache.avro.tool.Main.run(Main.java:84)
        at org.apache.avro.tool.Main.main(Main.java:73)

Argh, no way to understand what’s happening in the compiling process.

Can someone help me out this one???

Thanks, Phaedra.



Re: Hi to all, little problem when compiling avcr

Posted by Christophe Taton <ta...@wibidata.com>.
Hi,

It looks like you are invoking the Avro compiler for a schema instead of
for a protocol.
If you are running a command like this one:
    $ java -jar path/to/avro-tools.jar compile schema path/to/idl.avpr
path/to/generated

Then you should try:
    $ java -jar path/to/avro-tools.jar compile protocol path/to/idl.avpr
path/to/generated

C.


On Thu, Feb 6, 2014 at 1:14 AM, Casadio Phaedra <
Phaedra.Casadio@datamanagementpa.it> wrote:

> Hi to all, my name is Phaedra, i’m working in a company in Italy
> specialized in data management for public/private libraries.
>
> We are evaluating Avro for our rpc needs, for now Avro mapping seems to be
> really better than thrift or protobuf one.
>
>
>
> BUT, I’m stuck while compiling an avdl file to avcr file and then
> compiling to beans.
>
>
>
> IDL file example:
>
>
>
> *@namespace*("avro.bean")
>
> protocol MyProtocol {
>
>
>
>   record MyBean {
>
>     union { null, string } cd;
>
>     union { null, string } ds;
>
>   }
>
>
>
>   MyBean getMyBean(array<string> array);
>
> }
>
>
>
> Morph in to this:
>
>
>
> {
>
>   "protocol" : "MyProtocol",
>
>   "*namespace*" : "avro.bean",
>
>   "types" : [ {
>
>     "type" : "record",
>
>     "name" : "MyBean",
>
>     "fields" : [ {
>
>       "name" : "cd",
>
>       "type" : [ "null", "string" ]
>
>     }, {
>
>       "name" : "ds",
>
>       "type" : [ "null", "string" ]
>
>     } ]
>
>   } ],
>
>   "messages" : {
>
>     "getMyBean" : {
>
>       "request" : [ {
>
>         "name" : "array",
>
>         "type" : {
>
>           "type" : "array",
>
>           "items" : "string"
>
>         }
>
>       } ],
>
>       "response" : "MyBean"
>
>     }
>
>   }
>
> }
>
>
>
> For now, it’s going all as expected.
>
> BUT when I’m going to compile the schema:
>
>
>
> Input files to compile:
>
>   avro\idl.avpr
>
>
>
> Exception in thread "main" org.apache.avro.SchemaParseException: No type:
> {"protocol":"MyProtocol","namespace":"avro.bea
>
>
> n","types":[{"type":"record","name":"MyBean","fields":[{"name":"cd","type":["null","string"]},{"name":"ds","type":["null
>
>
> ","string"]}]}],"messages":{"getMyBean":{"request":[{"name":"array","type":{"type":"array","items":"string"}}],"response
>
> ":"MyBean"}}}
>
>         at org.apache.avro.Schema.getRequiredText(Schema.java:1221)
>
>         at org.apache.avro.Schema.parse(Schema.java:1082)
>
>         at org.apache.avro.Schema$Parser.parse(Schema.java:953)
>
>         at org.apache.avro.Schema$Parser.parse(Schema.java:922)
>
>         at
> org.apache.avro.tool.SpecificCompilerTool.run(SpecificCompilerTool.java:73)
>
>         at org.apache.avro.tool.Main.run(Main.java:84)
>
>         at org.apache.avro.tool.Main.main(Main.java:73)
>
>
>
> Argh, no way to understand what’s happening in the compiling process.
>
>
>
> Can someone help me out this one???
>
>
>
> Thanks, Phaedra.
>
>
>