Hbase shell - 如何写字节值 [英] Hbase shell - how to write byte value

查看:809
本文介绍了Hbase shell - 如何写字节值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在hbase中写一个65的值。我必须在hbase shell上运行以下命令:

 放置'table','key','cf:qual ','A'

但有没有办法直接编写它:


$ b $ pre $ 放置'table','key','cf:qual',65(尽管这是不允许的)

让我知道如果你明白这个问题,我会解释更多的。



更新:



到65我的意思是把'A'直接放在'A'的ascii值上。对我来说,真正的问题是我想把shell的值设置在128-255的范围内。

解决方案

既然Hbase Shell是使用ruby实现的,你可以通过用十六进制格式表示字节值来插入字节值。

lockquote

例如,如果你想插入一个字节值255:

255的十六进制表示是FF。
在Hbase shell中,我们应该给它作为stringBinary,它是\ 0xFF。

\x是一个特殊的转义字符,所以\xFF表示字节0xFF。

so 放置'table','rowkey','cf:qual' ,\xFF会插入字节255


重要说明:该值必须与in(双引号)不是'(单引号)。

有用的链接:



Ruby如何处理字节/二进制



十六进制数字(Hex-Codes)Cheatsheet


I want to write a value say 65 in hbase. I have to run the following command on hbase shell for that:

put 'table','key','cf:qual','A'

But is there a way to write it directly something like:

put 'table','key','cf:qual',65 (this is not allowed though)

Let me know if you understand the question else I will explain more.

Update:

By 65 I meant to put 'A' but directly the ascii value of 'A'. The real issue for me is I want to put values which fall in the range of 128-255 from the shell.

解决方案

Since Hbase Shell is implemented using ruby you can insert byte values by representing them in hexadecimal format.

For example if you want to insert a byte value 255:

hex representation of 255 is FF. In Hbase shell we should give it as stringBinary which is "\xFF"

The "\x" is a special escape character to encode an arbitrary byte from hex, so "\xFF" means byte 0xFF.

so put 'table', 'rowkey', 'cf:qual', "\xFF" will insert the byte 255

Important note: The value has to be with in " " (double quotes) not ' ' (single quotes).

Useful links:

How Does Ruby handle bytes/binary

Hexadecimal Digits (Hex-Codes) Cheatsheet

这篇关于Hbase shell - 如何写字节值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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