I want to write a value say 65 in hbase. I have to run the following command on hbase shell for that:
put 'table','key','cf:qual','A'
But is there a way to write it directly something like:
put 'table','key','cf:qual',65 (this is not allowed though)
Let me know if you understand the question else I will explain more.
Update:
By 65 I meant to put 'A' but directly the ascii value of 'A'. The real issue for me is I want to put values which fall in the range of 128-255 from the shell.
Since Hbase Shell is implemented using ruby, you can insert byte values by representing them in hexadecimal format.
For example if you want to insert a byte value 255
hex representation of 255 is FF. In Hbase shell we should give it as stringBinary which is "\xFF"
The "\x" is a special escape character to encode an arbitrary byte from hex, so "\xFF" means byte 0xFF.
so put 'table', 'rowkey', 'cf:qual', "\xFF"
will insert the byte 255
Note: The value has to be with in " " (double quotes) not ' ' (single quotes).
Useful links:
How Does Ruby handle bytes/binary
Hexadecimal Digits (Hex-Codes) Cheatsheet
you can also use Hbase built in functions like this
> put 'table','rowkey','cf:qua', Bytes.toBytes(1234)
it works for me.
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