在HBase中存储JSON并通过Id查询
我在 HBase 中存储 JSON 数据正确吗?
put 'messages', 123, 'cf:json', '{"foo":"bar"}'
基本上,我需要通过ID来查询它,在我的例子中是123。而 JSON 是变长字符串。
Am I correct of storing JSON data in HBase?
put 'messages', 123, 'cf:json', '{"foo":"bar"}'
Basically, I need to query it by ID, which is 123 in my example. And JSON is variable length string.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 JSON 存储在单元格值中没有问题。单元大小高达 5M 仍然是合理的。一般来说,虽然建议保持键和列的大小较小(http://hbase.apache.org/book.html#keysize),而 JSON 虽然比 XML 更紧凑,但仍然是一种浪费的格式(与二进制 JSON 相比) 、Thrift、Avro、MessagePack 等)。如果您继续使用 JSON,您可能需要考虑压缩列族
There's no problem storing JSON in a cell value. Cell sizes of up to 5M are still reasonable. Generally speaking though it is recommended to keep key and column sizes small (http://hbase.apache.org/book.html#keysize) and JSON, while being more compact than XML, is still a wasteful format (vs. binary JSON, Thrift, Avro, MessagePack etc.). if you stay with JSON you might need to consider making the column family compressed