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 3372B10EA2 for ; Mon, 27 Jan 2014 19:40:04 +0000 (UTC) Received: (qmail 73755 invoked by uid 500); 27 Jan 2014 19:40:03 -0000 Delivered-To: apmail-avro-user-archive@avro.apache.org Received: (qmail 73592 invoked by uid 500); 27 Jan 2014 19:40:02 -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 73584 invoked by uid 99); 27 Jan 2014 19:40:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Jan 2014 19:40:02 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lewis.mcgibbney@gmail.com designates 209.85.216.49 as permitted sender) Received: from [209.85.216.49] (HELO mail-qa0-f49.google.com) (209.85.216.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Jan 2014 19:39:56 +0000 Received: by mail-qa0-f49.google.com with SMTP id w8so7814684qac.36 for ; Mon, 27 Jan 2014 11:39:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=3U/I+dqmD1pYWJiHpmXY5DLTv3dxyXaveahU+WaZ88Q=; b=Rl7XazLMSceVGOuYegr0WdLO2L0fi6jgpN0uCH3ohB2fOUHdZMrYZgAtsL34x3TsTE wY/aoyfDDSLbfRiscC+sh6bzerikCLVIcCX7GPGtcNhDQoVM1NHwxH9bI2M52JUvn5aE 14wzZimzuAEFLwFtHdZo7dj1FPoC+BbrNEKTBMsmVL28VvINEVDfDsB+vPAjkCePmvqg Nqa85xgfvKBF3dnTV8OV2pCOqFftBpZpFFG7/eSwkggLEf9TtSsLmoVYaoh7Y7Ghng0d +k1uo3OUh4LB2Fz736aElFggFKBeSbE+k0ci5UTCoJoeJhHY1e35FsZTEVbgcK5SPGgh LjLw== MIME-Version: 1.0 X-Received: by 10.224.98.212 with SMTP id r20mr44782942qan.0.1390851574826; Mon, 27 Jan 2014 11:39:34 -0800 (PST) Received: by 10.96.224.67 with HTTP; Mon, 27 Jan 2014 11:39:34 -0800 (PST) Date: Mon, 27 Jan 2014 19:39:34 +0000 Message-ID: Subject: Clarification of getSchema()#getIndexNamed(fieldName) in Avro 1.7.5 Java API From: Lewis John Mcgibbney To: user@avro.apache.org Content-Type: multipart/alternative; boundary=089e0149d0d00dc8fe04f0f8de83 X-Virus-Checked: Checked by ClamAV on apache.org --089e0149d0d00dc8fe04f0f8de83 Content-Type: text/plain; charset=ISO-8859-1 Hi Folks, I have the following UNION field {"name": "url", "type": ["null","string"], "default":null}, Once I've generated the Persistent class, I set a vlue for this field as follows page.setUrl(new Utf8("example.org")); When however I attempt to get the field position of the URL UNION with int fieldIndex = persistent.getSchema().getIndexNamed(fieldName); I am thrown an org.apache.avro.AvroRuntimeException: Not a union {"type":"record","name":"WebPage",... blah blahblah ... "default":null}]} However if I do int fieldIndex = persistent.getSchema().getField(fieldName).pos(); This works perfectly fine... I've looked at this in my debugger for a bit and can't find a solution right now. Any ideas please? Thank you in advance Lewis -- *Lewis* --089e0149d0d00dc8fe04f0f8de83 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Folks,
I have th= e following UNION field

{"name": "url", "ty= pe": ["null","string"], "default":null},=

Once I've generated the Persistent class, I set a vlue for this fie= ld as follows

page.setUrl(new Utf8("example.org"));

When however I attempt to get the= field position of the URL UNION with

int fieldIndex =3D persistent.getSchema().getIndexNamed(fieldName);
I am thrown an org.apache.avro.AvroRuntimeException: Not a union {&quo= t;type":"record","name":"WebPage",... bl= ah blahblah ... "default":null}]}

However if I do

int fieldIndex =3D persistent.getSchema()= .getField(fieldName).pos();

This works perfectly fine...
I've looked at this in my debugger for a bit and can't find= a solution right now. Any ideas please?
Thank you in advance
Lewis

--
Lewis
--089e0149d0d00dc8fe04f0f8de83--