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 # user >> Explicit Values for Enums


Copy link to this message
-
Re: Explicit Values for Enums
Changing the serialization of schemas to use schema-specified values
would be difficult to achieve in a compatible manner.  However
changing the values used in some programming languages might not be
difficult.  In Java the ordinal value is not user-specifiable, but in
C and C++ it is.  So such a schema property might be used by the C++
code generator.

Doug

On Sun, Jun 2, 2013 at 1:35 PM, William McKenzie
<[EMAIL PROTECTED]> wrote:
> I did a few searches on Jira and couldn't find anything it, so apologies if
> this has been requested previously.
>
> It seems like it would be useful to allow an explicit value for enumeration
> members. I suppose the biggest argument against it would be that might have
> to be a breaking change to the schemas, since the current list of values is
> just an array of strings, but maybe it could be added as an optional schema
> field which would override the implicit sequential numbering.
>
> // Maybe?
> {
>      "type": "enum",
>      "name": "Roles",
>      "symbols": [ "Producer", "Consumer" ]
>      "values": [ 100, 101 ]
> }
>
> // This is just too ugly
> {
>      "type": "enum",
>      "name": "Roles",
>      "symbols": [ "Producer=100", "Consumer=101" ]
> }
>
> // Alternating strings and values? still pretty ugly.
> {
>      "type": "enum",
>      "name": "Roles",
>      "symbols": [ "Producer", 100,  "Consumer", 101 ]
> }
>
> ~Bill
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