avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rendy Bambang Junior <rendy.b.jun...@gmail.com>
Subject Re: Deserialize Avro Object Without Schema
Date Wed, 25 Mar 2015 12:43:54 GMT
So sample mentioned in Avro site and mentioned by others works because they
are in form of DataFile, and DataFile include the schema within. Got it.
Thank you Rob!


On Wed, Mar 25, 2015 at 6:04 PM, Rob Turner <robairrobair@gmail.com> wrote:

> Hi,
> Avro datafiles have a header that includes the schema that the data was
> written with. In your Kafka example the schema is not available. You could
> send an Avro Datafile in each message, possible having more that one datum
> in a batch, and use the DataFileReader. Another way is to include a schema
> id sent with each message and look the schema up in a repository, or you
> may just know the schema for the particular consumer topic.
> Regards
>    Rob Turner.
> On 25 March 2015 at 09:08, Rendy Bambang Junior <rendy.b.junior@gmail.com>
> wrote:
>> Hi,
>> I'm new in Avro. One of Avro's benefit is dynamic typing which code need
>> not to be generated to deserialize Avro schema.
>> I'm trying to find an example to deserialize Avro without specify the
>> schema but all of them require me to pass schema to GenericDatumReader
>> constructor or set the schema after construct the reader.
>> So, I'm wondering, *is it possible to deserialize Avro without defining
>> it's schema?*
>> I mean, it's like getting value from Map<String, Object> and cast to
>> desired data type without knowing the schema.
>> It should be possible right? Since the schema itself is embedded in the
>> data.
>> Attached my sample code, it get null pointer exception because I don't
>> specify the schema.
>> Thanks!
>> Rendy

View raw message