从 hbase 行检索时间戳
使用 Hbase API (Get/Put) 或 HBQL API,是否可以检索特定列的时间戳?
Using Hbase API (Get/Put) or HBQL API, is it possible to retrieve timestamp of a particular column?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
假设您的客户端已配置并且您有一个表设置。执行 get 返回一个 结果
结果是由 KeyValue 支持。 KeyValues 包含时间戳。您可以使用 list() 获取键值列表,也可以使用 raw() 获取数组。 KeyValue 有一个获取时间戳方法。
Assuming your client is configured and you have a table setup. Doing a get returns a Result
A Result is backed by a KeyValue. KeyValues contain the timestamps. You can get either a list of KeyValues with list() or get an array with raw(). A KeyValue has a get timestamp method.
@codingFoo 的答案假设所有单元格的所有时间戳都相同,但 op 的问题是针对特定列的。在这方面,类似于@peibin wang的答案,如果您想要专栏的最后一个时间戳,我会建议以下内容:
使用 getColumnLatestCell 对 Result 对象进行方法,然后调用
getTimestamp
方法如下:如果您想访问特定时间戳,您可以使用 getColumnCells 返回指定列的所有单元格,但随后您必须在带有 < 的单元格之间进行选择代码>获取(int index) 然后调用
getTimestamp()
@codingFoo's answer assumes all timestamps are the same for all cells, but op's question was for a specific column. In that respect, similar to @peibin wang's answer, I would propose the following if you would like the last timestamp for your column:
Use the getColumnLatestCell method on your Result object, and then call the
getTimestamp
method like so:If you want access to a specific timestamp you could use the getColumnCells which returns all cells for a specified column, but then you will have to choose between the cells with a
get(int index)
and then callgetTimestamp()
是一个很好的风格
is a good style
我认为以下会更好:
因为 Result#getValue(family, qualifier) 实现为
I think the follow will be better:
since Result#getValue(family, qualifier) is implemented as