Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Avro, mail # dev - Reading nested specific type


+
Bernd Fondermann 2013-05-06, 15:55
+
Doug Cutting 2013-05-06, 17:53
+
Doug Cutting 2013-05-06, 20:30
Copy link to this message
-
Re: Reading nested specific type
Doug Cutting 2013-05-06, 20:32
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"]
>>>                 }
>>>             ]
>>>         }
>>>     ]
>>> }
+
Bernd Fondermann 2013-05-07, 14:35
+
Doug Cutting 2013-05-07, 16:05
+
Bernd Fondermann 2013-05-07, 19:46
+
Doug Cutting 2013-05-07, 21:39
+
Bernd Fondermann 2013-05-08, 05:34