avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sharad Agarwal" <shara...@yahoo-inc.com>
Subject Re: question about referring to record names as type
Date Tue, 19 May 2009 12:43:49 GMT

Scott Banachowski wrote:
>
>
> Is the scope of the record only for the current record?
No. All types and messages which are part of the same protocol definition
file can refer to the record by name.

>
> Or, for example, if I had an record that defined 2 fields, each a
> record, could record 2 refer to record 1 by name?  And vise-versa (i.e.
> can we forward reference types not yet defined)?
>
Forward referencing is not allowed.

>
>
> {
>    "type": "record",
>    "name": "longlist",
>    "fields" : {
>      "nested1" : {
>          "type" : "record",
>         "name" : "rec1",
>         "fields" : {
>            "a":"long",
>            "b": "rec2" /* LEGAL? to refer to rec2? */
>          }
>        }
>      }
>      "nested2" : {
>          "type" : "record",
>         "name" : "rec2",
>         "fields" : {
>            "c":"long",
>            "d": "rec1" /* LEGAL? to refer to rec1? */
>          }
>      }
>      "contrived" : ["longlist", "rec1", "rec2"] /* LEGAL? */
>    }
> }
>
>
rec1 can't refer to rec2. However other way is legal.

>
> Also, can named fields also be referred to as types in other fields?
>
> {
>    "type": "record",
>    "name": "longlist",
>    "fields" : {
>      "value" : "long",
>      "next" : ["longlist", "null"],
>      "likenext" : "next" /* LEGAL? to refer to next as type? */
>    }
> }
>
Not Legal. "next" here is field identifier, not a type.

- Sharad

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message