[ 
https://issues.apache.org/jira/browse/AVRO-680?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12930215#action_12930215
 ] 

David Rosenstrauch commented on AVRO-680:
-----------------------------------------

I too see the logic behind AVRO-9.  But I'm also having a need in my code to 
create a map with non-string keys, and without that capability built-in, 
defining a schema to achieve that functionality is really ugly.  e.g.:

{code:java}
...
        {
                "name": "KVMappings",
                "type": {
                        "type": "array",
                        "items": {
                                "name": "KVMapping",
                                "type": "record",
                                "fields" : [
                                        {"name": "Key", "type": "long"},
                                        {"name": "Value", "type": "long"}
                                ]
                        }
                }
        }
{code}

Not to mention that the code for reading/writing to/from a record with such a 
schema is an ugly hack too.

Is there any way to add/restore the functionality make it possible for Avro to 
create non-string-based maps?

Perhaps a good implementation would be for string-based keys to be the default, 
but allowing the user to have the option to specify an alternate key type if 
they desire.

Thoughts?

> Allow for non-string keys
> -------------------------
>
>                 Key: AVRO-680
>                 URL: https://issues.apache.org/jira/browse/AVRO-680
>             Project: Avro
>          Issue Type: Improvement
>            Reporter: Jeremy Hanna
>
> Based on an email thread back in April, Doug Cutting proposed a possible 
> solution for having non-string keys:
> Stu Hood wrote:
> > I can understand the reasoning behind AVRO-9, but now I need to look for an 
> > alternative to a 'map' that will allow me to store an association of bytes 
> > keys to values.
> A map of Foo has the same binary format as an array of records, each
> with a string field and a Foo field.  So an application can use an array
> schema similar to this to represent map-like structures with, e.g.,
> non-string keys.
> Perhaps we could establish standard properties that indicate that a
> given array of records should be represented in a map-like way if
> possible?  E.g.,:
> {"type": "array", "isMap": true, "items": {"type":"record", ...}}
> Doug

-- 
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