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 Threaded View
Avro >> mail # user >> explicit schema verification?


Copy link to this message
-
Re: explicit schema verification?
Before the SpecificRecord  Builder API, a common practice was to use wrapper
classes and/or static helpers for your types so that users can only create
valid objects.

On 9/7/11 1:17 PM, "Yang" <[EMAIL PROTECTED]> wrote:

> when we declare some fields in a record, it's assumed to be mandatory unless
> we specify it with a union {original_type, null}.
>
> this feature is actually very useful to me: I declare a schema, and if some
> new user creates a record, but fails to populate some mandatory field, I want
> some mechanism to throw an exception.
>
> currently I get this feature "by accident": if the user misses some mandatory
> fields, when I send this record as a param to some RPC method, or when I
> serialize it through SpecificDatumWriter, Avro throws a NULLPointerException.
> I can catch this and let user know that it's due to lack of mandatory fields.
>
> but instead of NPE, could we make Avro throw a more explicit exception, so
> it's more descriptive?
>
> Thanks
> Yang
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