简体   繁体   English

Hbase Put时间戳(Java)和hbase shell时间戳

[英]Hbase Put timestamp (Java) and hbase shell timestamp

I have the following code: 我有以下代码:

table = new HTable(hbaseConf, targetTable);
byte[] key = "key7".getBytes();
Put put1 = new Put(key);
put1.add(OUT_CF, DATA_COL, Bytes.toBytes("data"));
table.put(put1);

When debugging I see that the default TS I am getting for the put object is 9223372036854775807. After the put I see in hbase shell that the TS is 1394640871745 (current time in ms as expected). 调试时,我看到放置对象的默认TS是9223372036854775807。放置后,我在hbase shell中看到TS是1394640871745(当前时间以毫秒为单位)。 Does anyone knows why? 有谁知道为什么? How to do the conversion? 怎么做转换?

Personally I don't know Hadoop, but following code produces same output as the default timestamp of your Put object: 我个人不了解Hadoop,但是以下代码产生的输出与Put对象的默认时间戳相同:

System.out.println(Long.MAX_VALUE); 
// Output: 9223372036854775807

So I assume that the Put -object just initializes its timestamp to Long.MAX_VALUE . 因此,我假设Put只是将其时间戳初始化为Long.MAX_VALUE Unfortunately I have not found this behaviour documented on the Apache website . 不幸的是,我在Apache网站上未发现此行为。

Edit: 编辑:

Since the documentation of Apache is very poor (not even explained what kind of timestamp they talk about) I have studied the source code and found my suspicion confirmed: 由于Apache的文档非常差(甚至没有解释他们谈论哪种时间戳),我研究了源代码并发现我的怀疑得到了证实:

public static final long LATEST_TIMESTAMP = Long.MAX_VALUE; 公共静态最终long LATEST_TIMESTAMP = Long.MAX_VALUE;

See also this code excerpt: 另请参见以下代码摘录:

   public Put(byte [] row) {
     this(row, null);
   }  

   public Put(byte [] row, RowLock rowLock) {
       this(row, HConstants.LATEST_TIMESTAMP, rowLock);
   }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM