[ 
https://issues.apache.org/jira/browse/HADOOP-6486?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Doug Cutting updated HADOOP-6486:
---------------------------------

    Status: Open  (was: Patch Available)

> Why is EnumSetWritable now a collection?

Type erasure.  Avro reflect knows how to infer a schema for any 
Collection<Foo>, but not for an arbitrary Wrapper<Foo>.  Consider, for example, 
the following code:

{code}
...
private static class Wrapper<T> {
T wrapped;
}
private Wrapper<String> wrapper;
...
{code}

Java reflection does not make it easy for one to infer a schema for 'wrapper'.  
The reflected type of that field is a ParametrizedType: Wrapper.class 
parameterized by String.class.  So one might then, to finding the schema for 
Wrapper.class, pass down String.class as a parameter, use 
Class#getTypeParameters() to bind T to String.class, then, when T is referenced 
in the type of the field "wrapped", lookup that binding.  I worry about scope 
issues, since the name T is scoped lexically, while walking the class structure 
is not, but perhaps that's not an issue.  So perhaps Avro reflect could 
correctly determine a schema for "wrapper", but, at present, it does not.

Also, representing EnumSetWritable as an array of enum values rather than a 
one-field-class that wraps an array of enum values seems like a better schema.

> fix common classes to work with Avro 1.3 reflection
> ---------------------------------------------------
>
>                 Key: HADOOP-6486
>                 URL: https://issues.apache.org/jira/browse/HADOOP-6486
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: ipc
>            Reporter: Doug Cutting
>            Assignee: Doug Cutting
>             Fix For: 0.22.0
>
>         Attachments: HADOOP-6486.patch, HADOOP-6486.patch, HADOOP-6486.patch, 
> HADOOP-6486.patch, HADOOP-6486.patch, HADOOP-6486.patch, HADOOP-6486.patch
>
>
> A few minor changes are required to get some common classes to work correctly 
> with Avro 1.3 reflection.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to