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 <[email protected]>
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
>

Reply via email to