FAQ
Calling toJson() on a Schema will print it in json fom. However you most
likely do not want to invent your own file format for Avro data.

DataFileWriter which will manage the schema for you, along with compression,
metadata, and the ability to seek to the middle of the file. Additionally
it is then readable by several other languages and tools.
On 1/7/13 4:42 AM, "Pratyush Chandra" wrote:

I am able to serialize with binary encoding to a file using following :
FileOutputStream outputStream = new FileOutputStream(file);
Encoder e = EncoderFactory.get().binaryEncoder(outputStream, null);
DatumWriter<GenericRecord> datumWriter = new
GenericDatumWriter<GenericRecord>(schema);
GenericRecord message1= new GenericData.Record(schema);
message1.put("to", "Alyssa");
datumWriter.write(message1, e);
e.flush();
outputStream.close();

But the output file contains only serialized data and not schema. How can I
add schema also ?

Thanks
Pratyush Chandra

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 5 | next ›
Discussion Overview
groupuser @
categoriesavro
postedJan 7, '13 at 12:42p
activeJan 9, '13 at 7:48p
posts5
users2
websiteavro.apache.org
irc#avro

2 users in discussion

Pratyush Chandra: 3 posts Scott Carey: 2 posts

People

Translate

site design / logo © 2021 Grokbase