You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Weishung Chung <we...@gmail.com> on 2012/10/04 07:42:50 UTC

question about hbase rest api decoding long value stored as byte array

Hi,

I store a long value as byte array in HBase cell using an Increment object.

When I try to access the value via javascript using rest api, how do I
decode the value ? It works fine for String value when using atob method
but somehow I couldn't decode the long value correctly :(

Thank you,
Wei Shung

Re: question about hbase rest api decoding long value stored as byte array

Posted by Weishung Chung <we...@gmail.com>.
I was running the hbase rest service and trying to access the data from
javascript client side.
Thank you :)

On Wed, Oct 3, 2012 at 11:44 PM, anil gupta <an...@gmail.com> wrote:

> Sorry, i don't know java script.
>
> On Wed, Oct 3, 2012 at 11:40 PM, Weishung Chung <we...@gmail.com>
> wrote:
>
> > Yes I know how to do that using java api. How about using javascript ?
> >
> > On Wed, Oct 3, 2012 at 11:22 PM, anil gupta <an...@gmail.com>
> wrote:
> >
> > > Hi Weishung,
> > >
> > > Since you stored the value as a long rather than String. You need to
> > > convert the byte [] of value into a Long. You can use the  following
> > method
> > > to convert byte[] into long.
> > > long
> > >
> >
> org.apache.hadoop.hbase.util.Bytes<eclipse-javadoc:%E2%98%82=hbase_resteasy/C:%5C/Users%5C/agupta5%5C/.m2%5C/repository%5C/org%5C/apache%5C/hbase%5C/hbase%5C/0.92.1-cdh4.0.1%5C/hbase-0.92.1-cdh4.0.1.jar%3Corg.apache.hadoop.hbase.util(Bytes.class%E2%98%83Bytes>
> > > .toLong(byte[] bytes)
> > >
> > > HTH,
> > > Anil Gupta
> > >
> > > On Wed, Oct 3, 2012 at 10:42 PM, Weishung Chung <we...@gmail.com>
> > > wrote:
> > >
> > > > Hi,
> > > >
> > > > I store a long value as byte array in HBase cell using an Increment
> > > object.
> > > >
> > > > When I try to access the value via javascript using rest api, how do
> I
> > > > decode the value ? It works fine for String value when using atob
> > method
> > > > but somehow I couldn't decode the long value correctly :(
> > > >
> > > > Thank you,
> > > > Wei Shung
> > > >
> > >
> > >
> > >
> > > --
> > > Thanks & Regards,
> > > Anil Gupta
> > >
> >
>
>
>
> --
> Thanks & Regards,
> Anil Gupta
>

Re: question about hbase rest api decoding long value stored as byte array

Posted by anil gupta <an...@gmail.com>.
Sorry, i don't know java script.

On Wed, Oct 3, 2012 at 11:40 PM, Weishung Chung <we...@gmail.com> wrote:

> Yes I know how to do that using java api. How about using javascript ?
>
> On Wed, Oct 3, 2012 at 11:22 PM, anil gupta <an...@gmail.com> wrote:
>
> > Hi Weishung,
> >
> > Since you stored the value as a long rather than String. You need to
> > convert the byte [] of value into a Long. You can use the  following
> method
> > to convert byte[] into long.
> > long
> >
> org.apache.hadoop.hbase.util.Bytes<eclipse-javadoc:%E2%98%82=hbase_resteasy/C:%5C/Users%5C/agupta5%5C/.m2%5C/repository%5C/org%5C/apache%5C/hbase%5C/hbase%5C/0.92.1-cdh4.0.1%5C/hbase-0.92.1-cdh4.0.1.jar%3Corg.apache.hadoop.hbase.util(Bytes.class%E2%98%83Bytes>
> > .toLong(byte[] bytes)
> >
> > HTH,
> > Anil Gupta
> >
> > On Wed, Oct 3, 2012 at 10:42 PM, Weishung Chung <we...@gmail.com>
> > wrote:
> >
> > > Hi,
> > >
> > > I store a long value as byte array in HBase cell using an Increment
> > object.
> > >
> > > When I try to access the value via javascript using rest api, how do I
> > > decode the value ? It works fine for String value when using atob
> method
> > > but somehow I couldn't decode the long value correctly :(
> > >
> > > Thank you,
> > > Wei Shung
> > >
> >
> >
> >
> > --
> > Thanks & Regards,
> > Anil Gupta
> >
>



-- 
Thanks & Regards,
Anil Gupta

Re: question about hbase rest api decoding long value stored as byte array

Posted by Weishung Chung <we...@gmail.com>.
Yes I know how to do that using java api. How about using javascript ?

On Wed, Oct 3, 2012 at 11:22 PM, anil gupta <an...@gmail.com> wrote:

> Hi Weishung,
>
> Since you stored the value as a long rather than String. You need to
> convert the byte [] of value into a Long. You can use the  following method
> to convert byte[] into long.
> long
> org.apache.hadoop.hbase.util.Bytes<eclipse-javadoc:%E2%98%82=hbase_resteasy/C:%5C/Users%5C/agupta5%5C/.m2%5C/repository%5C/org%5C/apache%5C/hbase%5C/hbase%5C/0.92.1-cdh4.0.1%5C/hbase-0.92.1-cdh4.0.1.jar%3Corg.apache.hadoop.hbase.util(Bytes.class%E2%98%83Bytes>
> .toLong(byte[] bytes)
>
> HTH,
> Anil Gupta
>
> On Wed, Oct 3, 2012 at 10:42 PM, Weishung Chung <we...@gmail.com>
> wrote:
>
> > Hi,
> >
> > I store a long value as byte array in HBase cell using an Increment
> object.
> >
> > When I try to access the value via javascript using rest api, how do I
> > decode the value ? It works fine for String value when using atob method
> > but somehow I couldn't decode the long value correctly :(
> >
> > Thank you,
> > Wei Shung
> >
>
>
>
> --
> Thanks & Regards,
> Anil Gupta
>

Re: question about hbase rest api decoding long value stored as byte array

Posted by anil gupta <an...@gmail.com>.
Hi Weishung,

Since you stored the value as a long rather than String. You need to
convert the byte [] of value into a Long. You can use the  following method
to convert byte[] into long.
long org.apache.hadoop.hbase.util.Bytes<eclipse-javadoc:%E2%98%82=hbase_resteasy/C:%5C/Users%5C/agupta5%5C/.m2%5C/repository%5C/org%5C/apache%5C/hbase%5C/hbase%5C/0.92.1-cdh4.0.1%5C/hbase-0.92.1-cdh4.0.1.jar%3Corg.apache.hadoop.hbase.util(Bytes.class%E2%98%83Bytes>
.toLong(byte[] bytes)

HTH,
Anil Gupta

On Wed, Oct 3, 2012 at 10:42 PM, Weishung Chung <we...@gmail.com> wrote:

> Hi,
>
> I store a long value as byte array in HBase cell using an Increment object.
>
> When I try to access the value via javascript using rest api, how do I
> decode the value ? It works fine for String value when using atob method
> but somehow I couldn't decode the long value correctly :(
>
> Thank you,
> Wei Shung
>



-- 
Thanks & Regards,
Anil Gupta