avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: How to add optional new record fields and/or new methods in avro-ipc?
Date Tue, 18 Oct 2011 17:38:53 GMT
On 10/18/2011 10:09 AM, Scott Carey wrote:
> On 10/18/11 9:47 AM, "Doug Cutting" <cutting@apache.org> wrote:
>> To amend this, you can use Avro's @Nullable annotation:
> 
> The problem is that this does not provide the ability to evolve schemas if
> you add a field
> since you would need @Default or something similar, as well:
> @Nullable
> @Default(null)

I don't think this is required.  The default value for a union is the
default value for its first branch.  A "null" schema needs no default.
So the schema ["null", "string"] needs to specify no default value while
the schema ["string", "null"] does.  Thus the best practice for nullable
values is to place the null first in the union.  This is what is done by
the @Nullable annotation.

Perhaps we should clarify this in the Specification?  We might state
that a "null" schema implicitly has a default value of null since that's
the only value its ever permitted to have anyway.

> Does reflect have any concept of default values?

No.  We could add an @Default annotation, I suppose.  But I don't think
this is needed for nullable stuff.

Doug

Mime
View raw message