Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro >> mail # user >> Embedding schema with binary encoding


Copy link to this message
-
Embedding schema with binary encoding
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