avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Koduri,Vinay" <Vinay.Kod...@Cerner.com>
Subject Re: Avro enum and passivity.
Date Tue, 16 Jul 2013 01:26:41 GMT
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{
    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).


On 7/15/13 7:01 PM, "Doug Cutting" <cutting@apache.org> wrote:

>On Mon, Jul 15, 2013 at 3:11 PM, Koduri,Vinay <Vinay.Koduri@cerner.com>
>> 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
>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.

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.

View raw message