在 HBase Shell 命令行正常查看十六进制编码的中文

Hbase查看十六进制代码:

hbase(main):050:0> scan 'test'
row                                              column+cell
 row-1                                           column=f:c1, timestamp=1587984555307, value=\xe7\xa6\x85\xe5\x85\x8b
 row-2                                           column=f:c2, timestamp=1587984555307, value=hbase\xe8\x80\x81\xe5\xba\x97
 row-3                                           column=f:c3, timestamp=1587984555307, value=hbase\xe5\xb7\xa5\xe4\xbd\x9c\xe7\xac\x94\xe8\xae\xb0
 row-4                                           column=f:c4, timestamp=1587984555307, value=\xe6\x88\x91\xe7\x88\xb1\xe4\xbd\xa0\xe4\xb8\xad\xe5\x9b\xbd\xef\xbc\x81
4 row(s) in 0.0190 seconds

用formatter 为tostring方法查看十六进制编码转为中文格式

hbase(main):051:0> scan 'test', {formatter => 'tostring'}
row                                              column+cell
 row-1                                           column=f:c1, timestamp=1587984555307, value=禅克
 row-2                                           column=f:c2, timestamp=1587984555307, value=hbase老店
 row-3                                           column=f:c3, timestamp=1587984555307, value=hbase工作笔记
 row-4                                           column=f:c4, timestamp=1587984555307, value=我爱你中国!
4 row(s) in 0.0170 seconds

查看列f:c4的内容

hbase(main):052:0> scan 'test', {formatter => 'tostring',limit=>1,column=>'f:c4'}
row                                              column+cell
 row-4                                           column=f:c4, timestamp=1587984555307, value=我爱你中国!
1 row(s) in 0.0180 seconds

使用formatter_class为org.apache.hadoop.hbase.util.bytes查看的内容

hbase(main):053:0> scan 'test', {formatter_class => 'org.apache.hadoop.hbase.util.bytes', formatter => 'tostring'}
row                                              column+cell
 row-1                                           column=f:c1, timestamp=1587984555307, value=禅克
 row-2                                           column=f:c2, timestamp=1587984555307, value=hbase老店
 row-3                                           column=f:c3, timestamp=1587984555307, value=hbase工作笔记
 row-4                                           column=f:c4, timestamp=1587984555307, value=我爱你中国!
4 row(s) in 0.0220 seconds

使用formatter_class为org.apache.hadoop.hbase.util.bytes查看列f:c4的内容

hbase(main):054:0> scan 'test', {formatter_class => 'org.apache.hadoop.hbase.util.bytes', formatter => 'tostring', column=>'f:c4'}
row                                              column+cell
 row-4                                           column=f:c4, timestamp=1587984555307, value=我爱你中国!
1 row(s) in 0.0220 seconds

使用属性columns为 ['f:c1:tostring','f:c2:tostring']查看内容

hbase(main):004:0> scan 'test', {columns => ['f:c1:tostring','f:c2:tostring'] }
row                                              column+cell
 row-1                                           column=f:c1, timestamp=1587984555307, value=禅克
 row-2                                           column=f:c2, timestamp=1587984555307, value=hbase老店
2 row(s) in 0.0180 seconds

使用属性columns为[f:c1:c(org.apache.hadoop.hbase.util.bytes).tostring]查看内容

hbase(main):003:0> scan 'test', {columns => ['f:c1:c(org.apache.hadoop.hbase.util.bytes).tostring','f:c3:c(org.apache.hadoop.hbase.util.bytes).tostring'] }
row                                              column+cell
 row-1                                           column=f:c1, timestamp=1587984555307, value=禅克
 row-3                                           column=f:c3, timestamp=1587984555307, value=hbase工作笔记
2 row(s) in 0.0160 seconds

使用属性columns为[f:c1:tostring]或[f:c4:c(org.apache.hadoop.hbase.util.bytes).tostring]查看内容

hbase(main):055:0> scan 'test', {columns => ['f:c1:tostring','f:c4:c(org.apache.hadoop.hbase.util.bytes).tostring'] }
row                                              column+cell
 row-1                                           column=f:c1, timestamp=1587984555307, value=禅克
 row-4                                           column=f:c4, timestamp=1587984555307, value=我爱你中国!
2 row(s) in 0.0290 seconds

查看某一行的内容

hbase(main):058:0> get 'test','row-2','f:c2:tostring'
column                                           cell
 f:c2                                            timestamp=1587984555307, value=get到了吗?好意思不帮我分享嘛~哈哈~
1 row(s) in 0.0070 seconds

注:

当value=\x80\x00\x00\x00,value=\x85\xC6\xBB\x02这种格式的代码使用formatter_class => 'org.apache.hadoop.hbase.util.bytes', formatter => 'tostring'转不了的情况下,可使用toInt方式尝试转码。使用toString还是使用toInt方法要根据value=\x80\x00\x00\x00的存储类型决定,若存储类型为string,使用tostring方法,反之若value存储类型为int,使用toint方法

hbase(main):053:0> scan 'test', {formatter_class => 'org.apache.hadoop.hbase.util.bytes', formatter => 'toInt'}
row                                              column+cell
 row-1                                           column=f:c1, timestamp=1587984555307, value=禅克
 row-2                                           column=f:c2, timestamp=1587984555307, value=hbase老店
 row-3                                           column=f:c3, timestamp=1587984555307, value=hbase工作笔记
 row-4                                           column=f:c4, timestamp=1587984555307, value=我爱你中国!
4 row(s) in 0.0220 seconds

hbase的存储形式

 

  • 1
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值