avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill de hOra <b...@dehora.net>
Subject Re: schema defaults not reflected in generated objects (1.3.2)
Date Mon, 07 Jun 2010 22:11:22 GMT
Scott Carey wrote:
> No, it should not initialize the field to the default.
> Default values are for readers, not writers.   The intended use case is schema evolution.

This means writers can't leverage schema defaults, so writers should do 
something like this?

  Message message = new Message();
  // no defaults set
  String quux = message
  message.foo=new Utf8(quux);

[ignoring that the writer needs to know the schema type]. I suspect 
people will just write in garbage (like empty strings).

 > A writer must always correctly provide
 > data for all of the fields in the schema it declared
 > it is writing.

Why is it incorrect to not provide defaults when defaults are  part of 
the schema author's intention? Or put another way, why is reader/writer 
asymmetry a goal under a given schema?

I see in the code that SpecificDatumWriter/GenericDatumWriter is passed 
the Schema - By all means crash on fields with no defaults, but I'm not 
clear on what harm is done by using default field data. The current code 
seems fragile in comparison.


View raw message