14

If I have a rowkey that is in Hexadecimal, like x00\x01 , how do I get that in the HBASE shell?

hbase(main):004:0> scan 'tsdb-tree'
ROW                 COLUMN+CELL
\x00\x01            column=t:tree, timestamp=1379421652764, value={"name":"...
Naman
  • 27,789
  • 26
  • 218
  • 353
Kyle Brandt
  • 26,938
  • 37
  • 124
  • 165

1 Answers1

27

You can reference it using a normal get command, but the hexadecimal key must be in double quotes, single quotes will not work:

For example you would use get 'tsdb-tree', "\x00\x01":

hbase(main):016:0> scan 'tsdb-tree'
ROW                                                                       COLUMN+CELL                                                                                                                                                                                                             
 \x00\x01                                                                 column=t:tree, timestamp=1379421652764, value={"name":"TestTree1","description":"","notes":"","strictMatch":false,"created":0,"enabled":false,"storeFailures":false}                                                    
 \x00\x01                                                                 column=t:tree_rule:0:0, timestamp=1379371753132, value={"type":"METRIC","field":"host","regex":"","separator":"","description":"","notes":"","level":0,"order":0,"treeId":1,"customField":"","regexGroupIdx":0,"displayF
                                                                          ormat":""}                                                                                                                                                                                                              
 \x00\x02                                                                 column=t:tree, timestamp=1379372909057, value={"name":"testTree2","description":"","notes":"","strictMatch":false,"created":0,"enabled":false,"storeFailures":false}                                                    
2 row(s) in 0.0300 seconds

hbase(main):017:0> get 'tsdb-tree', "\x00\x01"
COLUMN                                                                    CELL                                                                                                                                                                                                                    
 t:tree                                                                   timestamp=1379421652764, value={"name":"TestTree1","description":"","notes":"","strictMatch":false,"created":0,"enabled":false,"storeFailures":false}                                                                   
 t:tree_rule:0:0                                                          timestamp=1379371753132, value={"type":"METRIC","field":"host","regex":"","separator":"","description":"","notes":"","level":0,"order":0,"treeId":1,"customField":"","regexGroupIdx":0,"displayFormat":""}              
2 row(s) in 0.0140 seconds
Kyle Brandt
  • 26,938
  • 37
  • 124
  • 165
  • 2
    there are times when your hexadecimal rowkey will contain a ' " ' in it. i.e. `)\x93\x83\x5C\xD0\xD5B\xC4\x83q\xD3z\x17"\xC1\xFF` just escape the double quote inside with '\' i.e. `)\x93\x83\x5C\xD0\xD5B\xC4\x83q\xD3z\x17\"\xC1\xFF` – Engineiro Aug 19 '14 at 00:16
  • Is there a way to implement this in Java. I tried it here @ https://stackoverflow.com/questions/57391102/how-to-do-hbase-range-scan-for-hexadecimal-row-key , but still trying to figure how to do this. – CoolCK Aug 07 '19 at 10:08