On Mon, Jul 30, 2012 at 11:13 PM, Pablo Musa <pa...@psafe.com> wrote:
> Hey guys,
> in my application the HBase timestamp is used as version in my logic.
> I would like to know what is the best way to insert a new record and get its 
> timestamp.
>
> I have come up with two possibilities:
>
> /* I could force timestamp, but it is not a good idea since different servers
>  * write into HBase which could lead to crazy behavior */
> new Put(row, timestamp);
>
> /* Or I could write into HBase and read it back. But I don't know how much 
> overhead
>  * this option causes.*/
> @Override
> public void put(Put put) throws IOException {
>     byte[] row = put.getRow();
>     hTableInterface.put(put);
>     KeyValue kv = hTableInterface.get(new Get(row)).getColumnLatest(family, 
> qualifier);
>     long version = kv.getTimestamp();
> }
>
> Is there any better way to do it?
>

Not that I know of.

The latter is problematic because another client may have inserted a
version between your put and the get.  The former could work but it
depends on your applications version semantic.  Is it ok if another
client does an update with the same 'version/timestamp'?

St.Ack

Reply via email to