Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro >> mail # user >> Builder pattern and default values in records


Copy link to this message
-
Re: Builder pattern and default values in records
Thanks Doug.  I think I'll have some time in the coming weeks to work on
it.  I guess I'll go ahead and create a new issue so that we can discuss the
design.

-James
On Wed, Jun 15, 2011 at 5:34 AM, Doug Cutting <[EMAIL PROTECTED]> wrote:

> James,
>
> I don't know of anyone currently working on this.  It'd be great to have!
>
> Doug
>
> On 06/13/2011 08:37 PM, James Baldassari wrote:
> > Hi,
> >
> > I was confused about why the Avro compiler wasn't initializing my
> > record's member variables with the default values I specified in my
> > IDL/schema, and then I came across this thread which explained the issue:
> >
> > http://search-hadoop.com/m/iDVTn1JVeSR1
> >
> > In the above thread Doug made this comment:
> >
> > "Factory/builders are probably the best approach at present.  Ideally we
> > might generate accessor methods, track which fields have been set, and
> > then set unset fields to their default values before writing."
> >
> > That sounds like a good approach, using mutators to track which fields
> > have been set.  Records could also implement the builder pattern, which
> > would make it much more convenient to construct records by chaining
> > setter invocations.
> >
> > It looks like there has been some discussion of this in AVRO-726 and
> > AVRO-770, but there hasn't been much activity lately.  Is anyone
> > actively working on this?  If no one has the time, I would be glad to
> > work on a patch.
> >
> > -James
> >
>