HBase设置时间戳

use*_*722 5 java api hadoop hbase

我在使用java api设置行时间戳时遇到问题.

当我试图添加时间戳值来放置构造函数(或put.add())时没有任何反应,在从表中读取行后,我得到系统提供的时间戳.

public static boolean addRecord(String tableName, String rowKey,
    String family, String qualifier, Object value)
{
    try {
        HTable table = new HTable(conf, tableName);
        Put put = new Put(Bytes.toBytes(rowKey), 12345678l);
        put.add(Bytes.toBytes(family), Bytes.toBytes(qualifier), Bytes.toBytes(value.toString()));
        table.put(put);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
Run Code Online (Sandbox Code Playgroud)

HBase 0.92.1以独立模式运行.

在此先感谢您的帮助!

Har*_*non 8

最有可能的是,表中的行已经有时间戳> 12345678l.要确认不是这种情况,请尝试使用非常大的时间戳值Long.MAX_VALUE.

如果确实如此,您只需删除旧版本即可.然后这个条目就会显示出来.