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的存储形式