gpt4 book ai didi

Hbase shell - 如何写入字节值

转载 作者:行者123 更新时间:2023-12-04 05:12:33 32 4
gpt4 key购买 nike

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

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

但是有没有办法直接编写它,例如:
put 'table','key','cf:qual',65 (this is not allowed though)

如果你理解这个问题,请告诉我,否则我会解释更多。

更新:

65 我的意思是把“A”直接放在“A”的ascii值上。对我来说真正的问题是我想从 shell 中放入 128-255 范围内的值。

最佳答案

由于 Hbase Shell 是使用 ruby​​ 实现的,因此您可以通过以十六进制格式表示它们来插入字节值。

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


重要说明:该值必须在“”(双引号)中,而不是 ' '(单引号)。
有用链接:
How Does Ruby handle bytes/binary
Hexadecimal Digits (Hex-Codes) Cheatsheet

关于Hbase shell - 如何写入字节值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22682308/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com