avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arunasalam G <zealousa...@gmail.com>
Subject Re: Doubt in a AVRO scenario
Date Wed, 11 Feb 2015 09:26:42 GMT
Hi,

    We serialized the schema using the following code.

ByteArrayOutputStream out = new ByteArrayOutputStream();
BinaryEncoder encoder = EncoderFactory.get().binaryEncoder(out, null);
DatumWriter<Record> writer = new SpecificDatumWriter<Record>(schema);

                writer.write(record, encoder);
encoder.flush();
out.close();

Here, record is of type org.apache.avro.generic.GenericData.Record.

Thanks and Regards,
Arun G


On Wed, Feb 11, 2015 at 2:08 PM, Sean Busbey <busbey@cloudera.com> wrote:

> On Wed, Feb 11, 2015 at 1:24 AM, Arunasalam G <zealousarun@gmail.com>
> wrote:
>
>>
>> Our scenario is we have stored the data with schema added to it.
>>
>> I would like to make it more simple without bringing the Hbase into
>> consideration.
>>
>> We have an Avro data object which has both data and schema and is
>> serialized to Byte Array.
>> Is there any way to retrieve the schema from this ByteArray object?
>>
>> Lets assume that we don't know what schema is present in the incoming
>> object.
>> I could find that for an AVRO data file, its possible to retrieve the
>> schema from the file and similarly, is there any way for retrieving the
>> schema from a serialized byte array object?
>>
>>
> It depends entirely on how you serialized the schema + binary into the
> byte array. Did you use some library or can you briefly describe the method
> used?
>
> --
> Sean
>

Mime
View raw message