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 Plain View
Avro >> mail # dev >> Avro enum and passivity.


+
Koduri,Vinay 2013-07-15, 22:11
+
Doug Cutting 2013-07-16, 00:01
Copy link to this message
-
Re: Avro enum and passivity.
We are relying on a inhouse framework that uses
SpecificDatumReader(writternSchema, readerSchema) to read our avro objects
from underlying store.
As we do not have control before the schema is resolved, we are thinking
of something like this

Version 1:
protocol SampleProtocol {
 enum Suit{
  SPADES, HEARTS, CLUBS, UNSPECIFIED
 }
    record Card {
 string @enumType("Suit") suit;
 }
}

UNSPECIFIED is the fallback enum, as you mentioned.
Card has a suit attribute which is a string instead of enum
@enumType annotation is used to denote that this string can only have
values from the referred enum and is also used in code generation to
return a enum type.(This one needs to be tested).

Thoughts?
Vinay
On 7/15/13 7:01 PM, "Doug Cutting" <[EMAIL PROTECTED]> wrote:

>On Mon, Jul 15, 2013 at 3:11 PM, Koduri,Vinay <[EMAIL PROTECTED]>
>wrote:
>> I am curios why this was designed to be non-passive, rather than simply
>>ignoring the new value or giving a "special" unsupported enum value if
>>the enum is required.
>
>The standard resolution mechanism is fairly strict, not permitting
>missing fields or extra enum symbols.
>
>There are schema conventions one might adopt to loosen this.  One
>could add an "UNSPECIFIED" value to one's enums, or one could make the
>enum's optional (i.e., a union with null).
>
>We could develop a DatumReader that uses a non-standard resolution
>mechanism.  For example, one might use GenericDatumReader with the
>writer's schema to read the full written record, then use modified
>templates so that the compiler creates wrappers around this generic
>representation.  For example, the generated code for a Card might look
>like:
>
>class Card {
>  private GenericRecord value;
>  public Suit getSuit() { return
>Suit.valueOf(value.getField("suit").toString()); }
>}
>
>This would permit the data to be read and only throw an exception when
>one tried to access a record with the undefined symbol.
>
>Doug

CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.
+
Doug Cutting 2013-07-16, 18:09
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