I have the below row stored in a HBase table
DIEp(^o^)q3 column=DIE:ID, timestamp=1346194191174, value=\x00\x00\x00\x01
I am trying to access the value and convert it to its string representation which should be 1, but I don't get the right string representation when I cat this file (where my output is redirected to)
cat /hadoop/logs/userlogs/job_201209121654_0027/attempt_201209121654_0027_m_000000_0/stdout
I got something like this garbage NUL NUL NUL SOH
below is the code fragment that I am using.
byte[] result1 = value.getValue("DIE".getBytes(), "ID".getBytes());
String myresult = Bytes.toString(result1);
System.out.println(myresult);
The standard HBase way of string conversion is Bytes.toBytes(string) and Bytes.toString(bytes). But Jon Skeet is correct in that you need to consider how you put the data into the column in the first place. If you used Bytes.toBytes(int), then you need to convert your bytes back into an integer before you convert to a string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With