如何使用HBASE Shell获取一行,其中rowkey是十六进制的?

时间:2013-09-17 13:55:21

标签: hbase

如果我有一个十六进制的rowkey,比如x00\x01,那我在HBASE shell中如何get

hbase(main):004:0> scan 'tsdb-tree'
ROW                 COLUMN+CELL
\x00\x01            column=t:tree, timestamp=1379421652764, value={"name":"...

1 个答案:

答案 0 :(得分:20)

您可以使用普通的get命令引用它,但十六进制密钥必须是双引号,单引号不起作用:

例如,您可以使用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