Return-Path: Delivered-To: apmail-hadoop-avro-dev-archive@minotaur.apache.org Received: (qmail 29758 invoked from network); 5 Feb 2010 03:32:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Feb 2010 03:32:50 -0000 Received: (qmail 35146 invoked by uid 500); 5 Feb 2010 03:32:50 -0000 Delivered-To: apmail-hadoop-avro-dev-archive@hadoop.apache.org Received: (qmail 34939 invoked by uid 500); 5 Feb 2010 03:32:49 -0000 Mailing-List: contact avro-dev-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: avro-dev@hadoop.apache.org Delivered-To: mailing list avro-dev@hadoop.apache.org Received: (qmail 34919 invoked by uid 99); 5 Feb 2010 03:32:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Feb 2010 03:32:49 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Feb 2010 03:32:48 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 1293A29A0018 for ; Thu, 4 Feb 2010 19:32:28 -0800 (PST) Message-ID: <1875517697.58421265340748074.JavaMail.jira@brutus.apache.org> Date: Fri, 5 Feb 2010 03:32:28 +0000 (UTC) From: "Thiruvalluvan M. G. (JIRA)" To: avro-dev@hadoop.apache.org Subject: [jira] Updated: (AVRO-261) Allow Schemas to be immutable In-Reply-To: <26548362.1261162881296.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AVRO-261?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thiruvalluvan M. G. updated AVRO-261: ------------------------------------- Attachment: AVRO-261.patch Google's immutablemap seems promising. But I think I found a solution without using immutable maps. AVRO-388 added the _name_ field to _Schema.Field_. Schema.getFields(), which is a _LinkedHashMap_ is used for two purposes: - To iterate over the Fields. Since the _Field_ now has name, this use can be handled by a _List_. That is _getFields()_ can return _List_. - To get the Field for a given fieldname. This is a much less frequent use case. This can be achieved by adding a _getField(String)_ method in _Schema_. To implement it, we'll can a Map inside _RecordSchema_, but this map is not exposed outside _RecordSchema_. The _getFieldSchemas()_ method is longer required as its purpose can be served by the two methods (_List getFields()_ and _Field getField(String)_ above. As a consequence _setFields()_ can now take a _List_ instead of _LinkedHashMap_. To solve the problem with setProp(), I renamed it to addProp() and changed its semantics to allow only addition of new properties (no deletion or update) It turns out that the code in many places have become simpler with these changes. There is no performance impact. I tested with both pre- and post-AVRO-388 GenericDatumReader. > Allow Schemas to be immutable > ----------------------------- > > Key: AVRO-261 > URL: https://issues.apache.org/jira/browse/AVRO-261 > Project: Avro > Issue Type: New Feature > Components: java > Reporter: Kevin Oliver > Assignee: Thiruvalluvan M. G. > Priority: Minor > Attachments: AVRO-261.patch, AVRO-261.patch > > > It would be nice if there was the ability to have an immutable Schema in java. > Without this, it makes sharing schemas risky. Also, with this, we could (lazily) cache the hashCode which is a fairly expensive operation today, especially on something like a record. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.