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 

2010-04-16 



Lurga 



发件人: Scott Carey 
发送时间: 2010-04-16  01:17:09 
收件人: [email protected] 
抄送: 
主题: 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: https://issues.apache.org/jira/browse/AVRO-517.
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.
-Scott

Reply via email to