[英]How to retrieve row's last modification timestamp in HBase?
Does each Cell in returned Result object have same timestamp? 返回的Result对象中的每个Cell是否都具有相同的时间戳? Is it save to do something like this? 做这样的事是否省钱?
try (Table table = connectionFactory.getConnection().getTable(TABLE)) {
try (ResultScanner scanner = table.getScanner(generateScan(systemId))) {
for (Result result: scanner) {
if (result == null) {
break;
}
long ts = result.rawCells()[0].getTimestamp();
System.out.println("Row last update time: " + ts);
}
}
}
Will I obtain time stamp of the last row modification? 我将获得最后一行修改的时间戳吗?
Cells in Result can have different timestamp. Result中的单元格可以具有不同的时间戳。 Each cell is a combination of CF:C:V
, where CF
is column family, C
is a column and V
is a version. 每个单元格都是CF:C:V
的组合,其中CF
是列族, C
是列, V
是版本。 Even if you store only 1 version, you can update columns of a cell independently. 即使只存储一个版本,也可以独立更新单元格的列。 Cell timestamp is updated when you store something. 存储某些内容时,单元时间戳会更新。
For example you have table user
with cf:main
and two columns name
and age
. 例如,您的表user
具有cf:main
和两列name
和age
。 If you update both columns in same Put
they will have same timetamp. 如果您在同一个Put
更新两个列,则它们将具有相同的时间戳。 If you update only name
column, timestamps will be different. 如果仅更新name
列,则时间戳将不同。 So generally it depends on your usage pattern. 因此,通常取决于您的使用模式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.