Hbase shell - how to write a byte value

I want to write a value of 65 in hbase. I need to run the following command for the hbase shell:

put 'table','key','cf:qual','A' 

But is there a way to write directly something like:

 put 'table','key','cf:qual',65 (this is not allowed though) 

Let me know if you understand the question, which I will talk more about.

Update:

By 65 I wanted to put "A", but the ascii value of "A" directly. The real problem for me is that I want to put values ​​ranging from 128 to 255 from the shell.

+7
hbase
source share
2 answers

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 the value of byte 255:

the hexadecimal representation of 255 is FF. In the Hbase shell, we must specify it as a stringBinary, which is "\ xFF"

"\ x" is a special escape character for encoding an arbitrary byte from hexadecimal, so "\ xFF" means byte 0xFF.

therefore put 'table', 'rowkey', 'cf:qual', "\xFF" will insert bytes 255

Important Note: The value must be specified in "" (double quotation marks), not '' (single quotation marks).

Useful links:

How Ruby Handles Bytes / Bins

Hexadecimal digits (hexadecimal codes)

+11
source share

you can also use the built-in hbase features like

 > put 'table','rowkey','cf:qua', Bytes.toBytes(1234) 

he works for me.

+2
source share

All Articles