You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by devush <de...@gmail.com> on 2011/02/11 22:01:11 UTC
ToBytes or ToString
hi,
I want to have the fixed size row key. i want to see the key in the
shell also. Currently i have java Long as the key id, so the string
representation is 19 characters maximum. I am using java
String.format("%019d", myLongVariable).
I am not sure if this is the correct way. If i use bytes array
byte[] b = Bytes.toBytes(long), then i will have the length equal 8
which is correct as the SIZEOF_LONG is 8. But in this case i am not
able to see the decimal values in hbase shell.
what is the best way to handle this. My row is rather big, but
contains only the Long values i.e. digits.
thanks
devush.
Re: ToBytes or ToString
Posted by Stack <st...@duboce.net>.
Shell does lowest-common denominator printing out String version of
the row bytes escaping the non-printables.
If all your tables use longs for row keys, it wouldn't be hard hacking
the formatter to print actual long for row bytes.
If you do this:
stack-3:trunk Stack$ ./bin/hbase shell --help
HBase Shell command-line options:
format Formatter for outputting results: console | html.
Default: console
-d | --debug Set DEBUG log levels.
Notice how you can pass a 'format' to use outputting shell emissions.
If you read bin/hirb.rb, it seems like only console is implemented.
You could add in a formatter that wrote out rows however you wanted.
St.Ack
On Fri, Feb 11, 2011 at 1:01 PM, devush <de...@gmail.com> wrote:
> hi,
> I want to have the fixed size row key. i want to see the key in the
> shell also. Currently i have java Long as the key id, so the string
> representation is 19 characters maximum. I am using java
> String.format("%019d", myLongVariable).
>
> I am not sure if this is the correct way. If i use bytes array
>
> byte[] b = Bytes.toBytes(long), then i will have the length equal 8
> which is correct as the SIZEOF_LONG is 8. But in this case i am not
> able to see the decimal values in hbase shell.
>
> what is the best way to handle this. My row is rather big, but
> contains only the Long values i.e. digits.
>
> thanks
> devush.
>
Re: ToBytes or ToString
Posted by Ted Yu <yu...@gmail.com>.
Have you tried this ?
* Write a printable representation of a byte array.
*
* @param b byte array
* @return string
* @see #toStringBinary(byte[], int, int)
On Fri, Feb 11, 2011 at 1:01 PM, devush <de...@gmail.com> wrote:
> hi,
> I want to have the fixed size row key. i want to see the key in the
> shell also. Currently i have java Long as the key id, so the string
> representation is 19 characters maximum. I am using java
> String.format("%019d", myLongVariable).
>
> I am not sure if this is the correct way. If i use bytes array
>
> byte[] b = Bytes.toBytes(long), then i will have the length equal 8
> which is correct as the SIZEOF_LONG is 8. But in this case i am not
> able to see the decimal values in hbase shell.
>
> what is the best way to handle this. My row is rather big, but
> contains only the Long values i.e. digits.
>
> thanks
> devush.
>