nivance created AVRO-1440:
-----------------------------

             Summary: the  problem  of resolving schema 
                 Key: AVRO-1440
                 URL: https://issues.apache.org/jira/browse/AVRO-1440
             Project: Avro
          Issue Type: Bug
          Components: java
    Affects Versions: 1.7.5
         Environment: jdk1.7.0_45
            Reporter: nivance


In Apache Avro™ 1.7.5 Documentation, have a sentence like this:
{quote}Since both client and server both have the other's full schema, 
correspondence between same named fields, missing fields, extra fields, etc. 
can all be easily resolved.{quote}
*h1.But if client has two fields and server has three fields, the server can't 
resolve.*

*h3Client avsc:*
{"type":"record",
"name":"UserLess",
"namespace":"com.joyveb.test.bean",
"fields":
[{"name":"name","type":"string"},
{"name":"favoritenumber","type":"int"}]}

*serialize codes:*
ByteArrayOutputStream bao = new ByteArrayOutputStream();
GenericDatumWriter<Object> w = new 
GenericDatumWriter<Object>(userLess.getSchema());
Encoder e = EncoderFactory.get().binaryEncoder(bao, null);
w.write(object, e);
e.flush();
ByteBuffer.wrap(bao.toByteArray());

*h3Server avsc:*
{"type":"record",
"name":"UserMore",
"namespace":"com.joyveb.test.bean",
"fields":
[{"name":"name","type":"string"},
{"name":"favoritenumber","type":"int"},{"name":"favoritecolor","type":"string"}]}

*deserialize codes:*
BinaryDecoder in = DecoderFactory.get().binaryDecoder(bytes, null);
Object result = new GenericDatumReader<Object>(userMore.getSchema()).read(null, 
in);



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to