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
In addition to giving deprecation warnings in code that uses the
deprecated fields, the generated source files themselves generate warnings.

It would be nice if we had three code generation options configurable in
the maven plugin:

<fieldVisibility>public<fieldVisibility>     [For those that still would
like public member field access]
<fieldVisibility>public-deprecated<fieldVisibility>     [For migrating
from public to private, default for now]
<fieldVisibility>private<fieldVisibility>  [For those that want fields
hidden, possible future default]

I would move my current code to use 'public' because I don't yet want to
migrate to the builder since it is too slow currently, and I already have
wrapper classes hiding the fields from user code so it is of little use
for my legacy code.  When I migrate to private it would be nice to
temporarily use the deprecated option beforehand, but right now it is just
cluttering my build with several hundred deprecated warning messages.

I have created a ticket for the above.

We can also improve the performance of the builder, using bitmasks/BitSet
instead of byte[] for detecting when a field is set, along with fixing
On 1/5/12 1:17 AM, "James Baldassari" <[EMAIL PROTECTED]> wrote:
>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
>// Use of accessor/mutator:
>Person me = new Person();
>// Use of Builder:
>Person me2 =
>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.
>On Thu, Jan 5, 2012 at 3:31 AM, Karthik Sampath Kumar <[EMAIL PROTECTED]>
>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