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 # user >> Setting field default value's programmatically


+
Lewis John Mcgibbney 2013-10-26, 10:41
Copy link to this message
-
Re: Setting field default value's programmatically
On Sat, Oct 26, 2013 at 3:41 AM, Lewis John Mcgibbney
<[EMAIL PROTECTED]> wrote:
> 2) Why org.apache.avro.data.RecordBuilderBase#defaultValue(Field field) is
> not returning null if no default is specified in the schema... which is the
> case?

It returns null when null is the default value, but throws an error
when no default value is specified.  This is required for correct
behavior, since null values are invalid for many types.  That said,
one could define an alternate method that returns a type-specific
default value when none is specified.  Alternately, one could traverse
schemas and populate fields that have no specified default with a
type-specific default.  I haven't looked at the Gora code in question,
but perhaps there's an opportunity to pre-process the schemas there,
prior to Avro code generation?

Cheers,

Doug
+
Lewis John Mcgibbney 2013-10-27, 18:48
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