Return-Path: X-Original-To: apmail-avro-dev-archive@www.apache.org Delivered-To: apmail-avro-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 66F1718AB5 for ; Thu, 28 May 2015 18:01:05 +0000 (UTC) Received: (qmail 45322 invoked by uid 500); 28 May 2015 18:01:00 -0000 Delivered-To: apmail-avro-dev-archive@avro.apache.org Received: (qmail 45274 invoked by uid 500); 28 May 2015 18:01:00 -0000 Mailing-List: contact dev-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@avro.apache.org Delivered-To: mailing list dev@avro.apache.org Received: (qmail 45258 invoked by uid 99); 28 May 2015 18:00:59 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 May 2015 18:00:59 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 20479C97DB for ; Thu, 28 May 2015 18:00:59 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.108 X-Spam-Level: X-Spam-Status: No, score=-1.108 tagged_above=-999 required=6.31 tests=[RCVD_IN_MSPIKE_H2=-1.108, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id R0GJMIhAbN6V for ; Thu, 28 May 2015 18:00:50 +0000 (UTC) Received: from mail-pd0-f173.google.com (mail-pd0-f173.google.com [209.85.192.173]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id B1FA924CE6 for ; Thu, 28 May 2015 18:00:50 +0000 (UTC) Received: by pdbki1 with SMTP id ki1so47015936pdb.1 for ; Thu, 28 May 2015 11:00:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=OUou9LXQCncXWlDkUn6NCCJw2wtZG19GgojSo8OWjWs=; b=D+Ap48wklt0LG6HP43VQgRoKu/yXezocSkBNvS8BX3eIliYvah6dpVwgweVLVj86z6 1zPFCMPJyNffsVMpcrfufwJQw3QaSVqi/ygWobDEzsxH+ZWgOYSI+e83Bil7uMxLvcNd 8dHRxNf3zK89pXzHkmsYiE98vaQx8fe2RzvqO4jvppBPQIoejNllq7NhNd+bvol0fJGl pyvB4LRTqdi5HmbRDy20YZYoON3FneeVQHS3p1/Tu2G4Y2jaTudU6Mh+UexHRg/6Y8eE 8+iH3ptW5b4UHZMLv+FbDehE4HDjiXS2oGeTCpyhkLhk3X0eyIORttzpDZpTKFG/eu8f v/mQ== X-Gm-Message-State: ALoCoQmypzBXSKM4M1dvHc60MNJFY2vX2TQIZkwBZGdv2LjMDn8xA7sLXEtLYyvQkjZ0xEXLFZKp X-Received: by 10.68.135.36 with SMTP id pp4mr7899315pbb.134.1432836005128; Thu, 28 May 2015 11:00:05 -0700 (PDT) Received: from [172.16.3.91] ([74.217.76.11]) by mx.google.com with ESMTPSA id oo3sm3060754pac.31.2015.05.28.11.00.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 May 2015 11:00:03 -0700 (PDT) Message-ID: <556757A2.7030703@cloudera.com> Date: Thu, 28 May 2015 11:00:02 -0700 From: Ryan Blue User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: dev@avro.apache.org Subject: Re: Need review/merges for couple of pull requests References: <5512E56B.3010704@cloudera.com> <556644F3.2050509@cloudera.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit SG, The data ends up looking like this: {"id":1,"p":"parent data!","child":{"c":"child data!","parent":{"long":1}}} I produced that with avro-tools 1.7.6 and tojson. Here's the schema: { "type" : "record", "name" : "Parent", "fields" : [ { "name" : "id", "type" : "long" }, { "name" : "p", "type" : "string" }, { "name" : "child", "type" : { "type" : "record", "name" : "Child", "fields" : [ { "name" : "c", "type" : "string" }, { "name" : "parent", "type" : [ "null", "long", "Parent" ] } ], "logicalType" : "reference", "ref-field-name" : "parent" } } ], "logicalType" : "referenceable", "id-field-name" : "id" } rb On 05/28/2015 09:50 AM, S G wrote: > RB, > > Could you please attach the schema and the JSON serialized output from your > test-code as well? > My build environment is currently broken as I am grappling with some Java 8 > update issues. > > Thanks > SG > > > On Wed, May 27, 2015 at 3:28 PM, Ryan Blue wrote: > >> SG, >> >> Now that logical types are in, I had some time to look at this issue. >> Thanks for your patience on this. >> >> When I started looking at the use case, this began to look very much like >> a logical type issue. (I know, I've been saying that a lot.) When you >> write, you replace any referenced object with its id. When you read, you >> replace those ids with the correct object. I went ahead and implemented >> this using 2 logical types: Referenceable for an object with an id, and >> Reference for a record with a field that references another object by id. >> >> There were some trade-offs to this approach. For example, I had to use a >> logical type for the object containing the reference rather than for the >> reference itself because I used a callback to set the object once it is >> found. That happens because children with references to a parent are >> deserialized completely first. The parent is the last object to be >> assembled and passed to the logical type conversion. >> >> A bigger issue was that logical types are currently conservative and don't >> overlap with reflect types or anything that sets java-class. That means >> that this currently only works with generic types. But, I'd rather make >> logical types work for reflect than add more custom code to support this. >> Does that sound reasonable? >> >> I'm attaching a diff with the working test code so you can take a look at >> the approach. Let me know what you are thinking. >> >> rb >> >> On 05/20/2015 12:05 PM, S G wrote: >> >>> I am requesting some help with AVRO-695. >>> Here are some pieces from the last conversation. >>> >>> >>> Doug Cutting >>> >>> added >>> a comment - 02/Oct/14 21:19 >>> >>> Here's a modified version of the patch. It moves all significant changes >>> to >>> reflect. Since reflect is the only implementation that can generate an >>> appropriate schema, changes should be confined to there. >>> >>> The tests need to be updated, as they still assume generic. >>> >>> < >>> https://issues.apache.org/jira/browse/AVRO-695?focusedCommentId=14286370&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14286370 >>>> >>> Sachin Goyal >>> >>> added >>> a comment - 21/Jan/15 21:56 >>> >>> Here is a patch with the updated test-cases. >>> I also confirm that all my changes are there in the patch. >>> >>> >>> The patch was submitted in June 2014 and was very hot till October 2014. >>> Since then, there has been no action on this even though I have sent many >>> reminders in this group. >>> >>> I understand that everyone is very busy with their own stuff but I would >>> really appreciate if someone could help a fellow engineer in getting his >>> patch accepted. >>> It would encourage more participation as well as help people wanting to >>> use >>> Avro for circular references. >>> >>> Regards >>> SG >>> >> >> >> -- >> Ryan Blue >> Software Engineer >> Cloudera, Inc. >> > -- Ryan Blue Software Engineer Cloudera, Inc.