avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "nivance (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (AVRO-1440) the problem of resolving schema
Date Wed, 15 Jan 2014 12:16:21 GMT

     [ https://issues.apache.org/jira/browse/AVRO-1440?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

nivance updated AVRO-1440:
--------------------------

    Description: 
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}
*But if client has two fields and server has three fields, the server can't resolve.*

*Client 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());

*Server 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);

  was:
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}
*But if client has two fields and server has three fields, the server can't resolve.*

*Client 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());

*Server 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);


> 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}
> *But if client has two fields and server has three fields, the server can't resolve.*
> *Client 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());
> *Server 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)

Mime
View raw message