HBase Shell RowKey中的非十六进制字符是什么? [英] What are the non-hex characters in HBase Shell RowKey?

查看:631
本文介绍了HBase Shell RowKey中的非十六进制字符是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将密钥保存为字节数组.在HBase Shell中,当我查看密钥时,我看到非十六进制值...我没有启用任何编码,也没有启用任何压缩.

I am saving my key as a byte-array. In HBase Shell when I look at my key I see non-hex values...I do not have any encoding enabled, I do not have any compression enabled.

这是一个示例...什么是VNQ?什么是BBW?我猜正在进行某种编码吗?

Here is a sample...what is VNQ? what is BBW? I'm guessing there is some sort of encoding going on?

\xFB\xC6\xE8\x03\xF0VNQ\x8By\xF6\x89D\xC1\xBBW\x00\x00\x00\x00\x00\x00\x01\xF3\x00\x00\x00\x00\x00\x07\xA1\x1F

推荐答案

HBase shell使用称为字节数组的二进制字符串"(转义十六进制)表示形式来打印键/值(请参见

HBase shell uses something called a "binary string" (Escaped hexadecimal) representation of byte arrays to print out the keys/values (See Bytes.toStringBinary method). This method basically does one of the two things to every byte:

  1. 如果字节值在范围内,则将其转换为可打印(ASCII)表示形式.
  2. 如果字节值不在ASCII范围内,请将其转换为\ xHH(其中"H"代表十六进制数字).

想法是使用可打印的表示形式.如果您的键/值都是可打印的字符,那么外壳将不会打印出任何奇怪的\ xHH序列.

The idea is to use a printable representation. If your keys/values were all printable characters, then the shell would not print out any of those weird \xHH sequences.

如果您更喜欢十六进制表示,请在HBase shell中尝试以下操作:

If you prefer Hex representation instead, try the following in HBase shell:

> import org.apache.hadoop.hbase.util.Bytes
> Bytes.toHex(Bytes.toBytesBinary("\xFB\xC6\xE8\x03\xF0VNQ"))
> fbc6e803f0564e51

您可以修改hbase shell ruby​​包装器以使用toHex()方法而不是toStringBinary()来打印数据(或者更好;您可以为HBase提供一个补丁,以包括两个选项的标记,如果您愿意的话)它;请参见 HBase开发人员指南).

You can modify hbase shell ruby wrappers to use the toHex() method instead of the toStringBinary() to print out data (or better; you can contribute a patch to HBase to include a flag for the two choices if you feel like it; see HBase developer guide).

这篇关于HBase Shell RowKey中的非十六进制字符是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆