avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Check Peck <comptechge...@gmail.com>
Subject Re: How to get typed value from GenericRecord?
Date Fri, 25 Nov 2016 02:35:39 GMT
Can anyone help me with this?

On Thu, Nov 24, 2016 at 10:29 AM, Check Peck <comptechgeeky@gmail.com>
wrote:

> I am working with Avro and I have a GenericRecord. I want to extract
> clientId and deviceName from it. In the Avro Schema, clientId is integer
> and deviceName is String. My question is - what is the recommended way to
> retrieve a typed value, as opposed to an Object or extracting everything as
> a String and then converting it back to original data type?
>
> In the below code, payload is GenericRecord. This is what I am doing
> right now, extracting everything as a String. But how can I just get typed
> value instead. Is there any way? I mean whatever the data type is there in
> the avro schema, I want to extract that only.
>
> String id = String.valueOf(payload.get("clientId"));String name = String.valueOf(payload.get("deviceName"));
>
>

Mime
View raw message