Hi,

I have a a csv string which I want to serialize, compress and write to a database.
*
I have the following code to serialize the string*

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Encoder e = EncoderFactory.get().binaryEncoder(outputStream, null);
GenericDatumWriter w = new GenericDatumWriter(schema);
w.write(record, e)
byte[] avroBytes = outputStream.toByteArray();


*Following code to de-serialize and process the record.*

DatumReader<GenericRecord> reader = new GenericDatumReader<GenericRecord>(schema);

 Decoder decoder = DecoderFactory.get().binaryDecoder(avroBytes, null);

GenericRecord record = reader.read(decoder, null);


I find compression with DataFileWriter and DataFileReader. But how to enable the compression for avro serialized buffer.

Thanks and Regards,
Vinod

Reply via email to