Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro >> mail # dev >> Reading nested specific type


Copy link to this message
-
Re: Reading nested specific type
Bernd,

I also note that in the schema you provided above that the "type"
field contains a union containing a single element.  Is that
intentional?  If not, you have an extra set of square brackets around
"WPPageType".

Doug

On Mon, May 6, 2013 at 1:30 PM, Doug Cutting <[EMAIL PROTECTED]> wrote:
> I filed the bug and attached a patch:
>
> https://issues.apache.org/jira/browse/AVRO-1320
>
> Does this fix things for you?
>
> Thanks,
>
> Doug
>
> On Mon, May 6, 2013 at 10:53 AM, Doug Cutting <[EMAIL PROTECTED]> wrote:
>> This looks like a bug.  I can reproduce it.  Please file an issue in Jira.
>>
>> Thanks,
>>
>> Doug
>>
>> On Mon, May 6, 2013 at 8:55 AM, Bernd Fondermann
>> <[EMAIL PROTECTED]> wrote:
>>> Hi all,
>>>
>>> I have an avro schema with nested types, which is used to write a trevi
>>> file.
>>> When reading/iterating the file using the outer specific type (WPPage), the
>>> nested type (WPPageType, an enum) is only initialized as an int, the nested
>>> enum type itself is not used. only after changing the generated code for
>>> setting the WPPageType field in WPPage.put() this works.
>>>
>>> What am I doing wrong?
>>>
>>> Thanks,
>>>
>>>   Bernd
>>>
>>> this is the original field setter:
>>>     case 3: type = (java.lang.Object)value$; break;
>>> this is my modified setter:
>>>     case 3: type = value$ == null ? null :
>>> (generated.WPPageType)WPPageType.values()[(Integer)value$]; break;
>>>
>>> this is my schema:
>>>
>>> {
>>>     "namespace": "generated",
>>>     "type": "record",
>>>     "name": "WPPage",
>>>     "fields": [
>>>         {
>>>             "name": "name",
>>>             "type": "string"
>>>         },
>>>         {
>>>             "name": "size",
>>>             "type": "int"
>>>         },
>>>         {
>>>             "name": "links",
>>>             "type": {
>>>                 "type": "array",
>>>                 "items": "string"
>>>             }
>>>         },
>>>         {
>>>             "name": "type",
>>>             "type": [
>>>                 {
>>>                     "namespace": "generated",
>>>                     "name": "WPPageType",
>>>                     "type": "enum",
>>>                     "symbols": ["article", "redirect", "disambiguation"]
>>>                 }
>>>             ]
>>>         }
>>>     ]
>>> }
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB