Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro, mail # user - Deprecation warnings in generated source code


Copy link to this message
-
Re: Deprecation warnings in generated source code
James Baldassari 2012-01-05, 09:17
Hi,

Since the Builder API was introduced
(AVRO-839<https://issues.apache.org/jira/browse/AVRO-839>released in
v1.6.0), direct access to record fields has been deprecated.
In some future version of Avro these fields will probably be made private.
The preferred way to access the fields in Avro 1.6.0 and later is to use
the associated getter/setter methods on the record or to use the Builder
API.  For example, if your record is called Person, you could do either of
the following:

// Use of accessor/mutator:
Person me = new Person();
me.setName("James");
me.setEmail("root@localhost");
System.out.println(me.getName());

// Use of Builder:
Person me2 = Person.newBuilder().setName("James").setEmail("root@localhost
").build();
System.out.println(me.getEmail());

There is a bit of a performance penalty with using the builder, but
hopefully that will be reduced somewhat when
AVRO-985<https://issues.apache.org/jira/browse/AVRO-985>is resolved.

-James
On Thu, Jan 5, 2012 at 3:31 AM, Karthik Sampath Kumar <[EMAIL PROTECTED]>wrote:

> I have 2 fields in .avsc file
>
>         {"name": "name", "type": "string"},
>         {"name": "email", "type": "string"},
>
> I get the following in generated  source code. Why does it contain  *
> @Deprecated* on the generated source code?
>
> *  @Deprecated* public java.lang.CharSequence name;
>   *@Deprecated* public java.lang.CharSequence email;
>
> It occurs only in version* 1.6.1 *of the avro-maven-plugin
> This doesn't happen when I use the 1.5.1 version
>
>
>