avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: schema defaults not reflected in generated objects (1.3.2)
Date Mon, 07 Jun 2010 21:44:20 GMT
On 06/07/2010 01:53 PM, Bill de hOra wrote:
> I.m wondering if I'm missing an incantation for 'compile
> schema/protocol' in Avro tools to handle defaults. Given this schema,

In Avro, default values are used by a reader when a writer's schema 
lacks a field.  This permits one to add a new field and still process 
data written before that field was added, provided one specifies a 
default value for the new field.  Similarly, if one removes a field, 
older code may still process the data, provided it has a default value.

This is related but not the same as the default value for a Java 
instance.  When one manually specifies a default value for a field in 
Java, one does not do this not primarily in order to future-proof the 
class, but typically so that one can avoid having to explicitly set the 
value somewhere else.  What both concepts have in common is that they 
permit a developer to provide a reasonable value to be used when no more 
specific value is known.

So it might be a useful feature if Java instance default values were 
acquired from the schema.  For one thing, folks seem to expect it.  But, 
from Avro's perspective, I don't think it's a bug.

Does that make sense?

Doug

Mime
View raw message