Return-Path: Delivered-To: apmail-avro-user-archive@www.apache.org Received: (qmail 57786 invoked from network); 2 Aug 2010 17:54:06 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Aug 2010 17:54:06 -0000 Received: (qmail 45574 invoked by uid 500); 2 Aug 2010 17:54:06 -0000 Delivered-To: apmail-avro-user-archive@avro.apache.org Received: (qmail 45491 invoked by uid 500); 2 Aug 2010 17:54:05 -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 45475 invoked by uid 99); 2 Aug 2010 17:54:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Aug 2010 17:54:05 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.9] (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 02 Aug 2010 17:54:02 +0000 Received: (qmail 57732 invoked by uid 99); 2 Aug 2010 17:53:41 -0000 Received: from localhost.apache.org (HELO [192.168.168.134]) (127.0.0.1) (smtp-auth username cutting, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Aug 2010 17:53:41 +0000 Message-ID: <4C570620.4040903@apache.org> Date: Mon, 02 Aug 2010 10:53:36 -0700 From: Doug Cutting User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100713 Thunderbird/3.0.6 MIME-Version: 1.0 To: user@avro.apache.org Subject: Re: Default values not supported in the client write? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On 08/02/2010 09:51 AM, Tim Robertson wrote: > http://www.mail-archive.com/avro-dev@hadoop.apache.org/msg04063.html > tells me that defaults aren't used at write time, but it means that I > have to initiate all the Strings with "=new Utf8();" each time I > create a message payload - is this correct? Defaults must used at read time. This is is a requirement. But that doesn't mean they cannot be used elsewhere, as a feature of a particular implementation. > I wonder the reasoning behind not initializing with null types (e.g. > for String using new Utf8()) in the client generation. There's a performance concern, since if user code subsequently sets the value, then the 'new Utf8("")' from the default value would still be executed. Using constants for default values could fix that, but, since values are reused, constants are not safe. > It means I > either need to modify the generated sources, or wrap them in some kind > of factory/builder right? Is that a common practice for avro or are > others doing something different? 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. Doug