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 <cutt...@apache.org> 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 <cutt...@apache.org> 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
>> <bernd.fonderm...@gmail.com> 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"]
>>>                 }
>>>             ]
>>>         }
>>>     ]
>>> }

Reply via email to