|
|
-
question about hbase rest api decoding long value stored as byte array
Weishung Chung 2012-10-04, 05:42
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
+
Weishung Chung 2012-10-04, 05:42
-
Re: question about hbase rest api decoding long value stored as byte array
anil gupta 2012-10-04, 06:22
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 <[EMAIL PROTECTED]> 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
+
anil gupta 2012-10-04, 06:22
-
Re: question about hbase rest api decoding long value stored as byte array
Weishung Chung 2012-10-04, 06:40
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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> > 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 >
+
Weishung Chung 2012-10-04, 06:40
-
Re: question about hbase rest api decoding long value stored as byte array
anil gupta 2012-10-04, 06:44
Sorry, i don't know java script.
On Wed, Oct 3, 2012 at 11:40 PM, Weishung Chung <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> > > 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
+
anil gupta 2012-10-04, 06:44
-
Re: question about hbase rest api decoding long value stored as byte array
Weishung Chung 2012-10-04, 06:51
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 <[EMAIL PROTECTED]> wrote:
> Sorry, i don't know java script. > > On Wed, Oct 3, 2012 at 11:40 PM, Weishung Chung <[EMAIL PROTECTED]> > 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 <[EMAIL PROTECTED]> > 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 <[EMAIL PROTECTED]> > > > 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 >
+
Weishung Chung 2012-10-04, 06:51
|
|