You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by 20...@web.de on 2011/05/20 11:32:58 UTC

GenericRecord get java native type

Hi,
just a short question. Is there any way to retrieve a native java int from a Generic Record (without creating an additional object).
This seems kind of trivial question, but I haven't seen yet how to do it.
Thanks
JS

  GenericRecord rec = null;
    ...
              try {
                  rec = r1.read(null, decoder);
                  sourceIP[i] =  rec.get("sourceIP").toString();
                  //same with int????

Re: GenericRecord get java native type

Posted by Scott Carey <sc...@richrelevance.com>.
Not currently, GenericRecord is internally an Object[].  It won't create
an extra object on read, it creates the boxed object during
deserialization.


On 5/20/11 2:32 AM, "20seconds@web.de" <20...@web.de> wrote:

>Hi,
>just a short question. Is there any way to retrieve a native java int
>from a Generic Record (without creating an additional object).
>This seems kind of trivial question, but I haven't seen yet how to do it.
>Thanks
>JS
>
>  GenericRecord rec = null;
>    ...
>              try {
>                  rec = r1.read(null, decoder);
>                  sourceIP[i] =  rec.get("sourceIP").toString();
>                  //same with int????