Return-Path: X-Original-To: apmail-avro-user-archive@www.apache.org Delivered-To: apmail-avro-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4C2A36BBB for ; Mon, 13 Jun 2011 18:38:08 +0000 (UTC) Received: (qmail 56970 invoked by uid 500); 13 Jun 2011 18:38:08 -0000 Delivered-To: apmail-avro-user-archive@avro.apache.org Received: (qmail 56934 invoked by uid 500); 13 Jun 2011 18:38:08 -0000 Mailing-List: contact user-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@avro.apache.org Delivered-To: mailing list user@avro.apache.org Received: (qmail 56926 invoked by uid 99); 13 Jun 2011 18:38:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Jun 2011 18:38:08 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jbaldassari@gmail.com designates 209.85.210.43 as permitted sender) Received: from [209.85.210.43] (HELO mail-pz0-f43.google.com) (209.85.210.43) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Jun 2011 18:38:01 +0000 Received: by pzk1 with SMTP id 1so2473500pzk.30 for ; Mon, 13 Jun 2011 11:37:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=DpKYQgAGhNngPDLEdRnhfMgLtb7PwOczRujR/Db+ilQ=; b=YzBN3sGzxN9qPobiWA5pEwth6ehEiKubCrulwdtTD4EqBc7a2gryWrY7p1kEwmq7Z3 gvr1uxQKgXFeeOOh+atXOibaWg84nekdOYNB5FVerZkvN50O/LONiPLGOh6v92734cPI F4yJGp0ymD+vF7jAQPQILZiFv2UsD9gTdsW/8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=qc275/Jad3Dk0+hqEWdpbbMoifVKchEOdE99FQnGPrhdhh4fvBD+zqfBN+wvxTqAqF uKFOh8nqT3pwmtXtlU9wuvtYf9D73fsJ7FKCO7n1RXeULQj+++jiPUQttliuq74IvKCs 486+Y5i4fdpQTBRWxaa2nNMrsVRN9EZMNiZAU= MIME-Version: 1.0 Received: by 10.68.39.105 with SMTP id o9mr2289288pbk.45.1307990259943; Mon, 13 Jun 2011 11:37:39 -0700 (PDT) Received: by 10.68.52.161 with HTTP; Mon, 13 Jun 2011 11:37:39 -0700 (PDT) Date: Mon, 13 Jun 2011 14:37:39 -0400 Message-ID: Subject: Builder pattern and default values in records From: James Baldassari To: user@avro.apache.org Content-Type: multipart/alternative; boundary=bcaec520e5abd04a1c04a59c36de X-Virus-Checked: Checked by ClamAV on apache.org --bcaec520e5abd04a1c04a59c36de Content-Type: text/plain; charset=ISO-8859-1 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 --bcaec520e5abd04a1c04a59c36de Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi,

I was confused about why the Avro compiler wasn't initializi= ng 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-hadoo= p.com/m/iDVTn1JVeSR1

In the above thread Doug made this comment:=

"Factory/builders are probably the best approach at present. = =A0Ideally 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.=A0 Records could also implement the builder pattern, which would= make it much more convenient to construct records by chaining setter invoc= ations.

It looks like there has been some discussion of this in AVRO-726 and AV= RO-770, but there hasn't been much activity lately.=A0 Is anyone active= ly working on this?=A0 If no one has the time, I would be glad to work on a= patch.

-James

--bcaec520e5abd04a1c04a59c36de--