avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lurga" <lurga....@gmail.com>
Subject Re: Re: Question on writing/reading file with different schema
Date Fri, 16 Apr 2010 01:29:58 GMT
Thanks a lot!
I'm a newbie. I want to learn how to use avro/java, but there's few examples. When I followed
the example in [1], I met this problem.
[1] http://hadoop.apache.org/avro/docs/current/api/c/index.html#_examples 



发件人: Scott Carey 
发送时间: 2010-04-16  01:17:09 
收件人: avro-user@hadoop.apache.org 
主题: Re: Question on writing/reading file with different schema 
It appears there is a bug in the ResolvingDecoder when the actual schema has trailing fields
not in the expected schema.  I have not had time to track it down.  I filed a JIRA ticket:
I have a suggested work-around.  You probably don't want to explicitly use a different reader
schema than the file.  The primary use case of the schema resolving is for schema evolution
and migration.  Most of the time a single version of an application will want to use a single
schema to represent the data.
If you simply want to read 2 of 3 fields, read 2 of three fields from the full schema -- don't
define a schema with only 2 of the three fields.
Every client can use the full "Person" schema, but wrapper classes or helper methods can read
the subset of the fields they want to.
In the example below, browseAge() and browseName() can use personSchema, there is no need
to create or manage the other two schemas.  I am not sure if that applies to your real-world
usage, but it likely does.
View raw message