Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HBase setting timestamp

I'm having problems setting row timestamp using java api.

When I'm trying to add a timestamp value to put constructor (or into put.add()) nothing happens and after reading rows from table I get system provided timestamps.

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;
    }
}

HBase 0.92.1 running in standalone mode.

Thanks in advance for any help!

like image 793
user898722 Avatar asked May 31 '12 09:05

user898722


1 Answers

Most likely, you already have rows in the table that have timestamp > 12345678l. To confirm that this is not the case, try it with a very large value for timestamp, say Long.MAX_VALUE.

If it is indeed the case, you can simply delete the older versions. Then this entry will show up.

like image 74
Hari Menon Avatar answered Nov 09 '22 23:11

Hari Menon