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 74BDEECD4 for ; Thu, 28 Feb 2013 18:04:56 +0000 (UTC) Received: (qmail 93738 invoked by uid 500); 28 Feb 2013 18:04:56 -0000 Delivered-To: apmail-avro-user-archive@avro.apache.org Received: (qmail 93681 invoked by uid 500); 28 Feb 2013 18:04:56 -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 93673 invoked by uid 99); 28 Feb 2013 18:04:56 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Feb 2013 18:04:56 +0000 Received: from localhost (HELO mail-ve0-f180.google.com) (127.0.0.1) (smtp-auth username cutting, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Feb 2013 18:04:55 +0000 Received: by mail-ve0-f180.google.com with SMTP id jx10so2067872veb.25 for ; Thu, 28 Feb 2013 10:04:54 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.52.19.239 with SMTP id i15mr2535925vde.47.1362074694389; Thu, 28 Feb 2013 10:04:54 -0800 (PST) Received: by 10.58.179.70 with HTTP; Thu, 28 Feb 2013 10:04:54 -0800 (PST) In-Reply-To: References: <1362021493836-4026430.post@n3.nabble.com> Date: Thu, 28 Feb 2013 10:04:54 -0800 Message-ID: Subject: Re: Incorrect Json schema generated for @java_class From: Doug Cutting To: user@avro.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable You could get the specific compiler to emit the desired type by modifying the method SpecificCompiler#getStringType() to take the Schema as a parameter and, if it has a java-class attribute, return that. Then things should work so long as you use ReflectDatumReader and ReflectDatumWriter. Would that suffice? Doug On Thu, Feb 28, 2013 at 9:25 AM, Alexandre Normand wrote: > Hey Doug, > I was also wondering about something related. In reflection, we can use t= he > java-class property to define the java class for stringable types. Could = we > find a way to bring some of this to the Specific generated classes so tha= t a > stringable type (I'm specifically thinking of BigDecimal and BigInteger) > could be exposed as the java-class type instead of Strings? I started > looking into this and there seem to be two possibilities, none of which I= 'm > terribly excited about: > > 1. Use some reflection to invoke the string constructor for the > java-class=E2=80=A6but that seems dirty as the Specific API probably shou= ldn't do > reflection, right? > 2. Handle a very specific list of java-class types (such as BigDecimal an= d > BigInteger) and have code that deals specifically with these in > Reader/Writer. > > Thoughts? > -- > Alex > > On Thursday, February 28, 2013 at 9:19 AM, Doug Cutting wrote: > > Annotation names in IDL are copied directly to schema properties with > the same names. > > The bug is in the IDL documentation, which uses the annotation > @java_class in an example, which is meaningless. The Java > implementation requires the "java-class" schema property, so the > annotation used should be @java-class. > > I filed an issue in Jira for this. > > https://issues.apache.org/jira/browse/AVRO-1264 > > Doug > > On Wed, Feb 27, 2013 at 7:18 PM, avronewbie wrote: > > For the IDL field: > > @java_class("java.util.ArrayList") array arrayOfInts; > > the JSON schema generated by the avro-maven-plugin is > > {\"name\":\"arrayOfInts\",\"type\":{\"type\":\"array\",\"items\":\"int\",= \"java_class\":\"java.util.ArrayList\"}} > > Shouldn't it be generated in JSON as java-class (with hypen instead of > underscore) instead of java_class? Because of this reading from avro file= is > not working. > > > > > -- > View this message in context: > http://apache-avro.679487.n3.nabble.com/Incorrect-Json-schema-generated-f= or-java-class-tp4026430.html > Sent from the Avro - Users mailing list archive at Nabble.com. > >