You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Pablo Musa <pa...@psafe.com> on 2012/08/01 00:23:02 UTC

RE: Retrieve Put timestamp

> What do you mean by using TS as version?

My application uses versioning between client and server. So I am using the timestamp as a version.

> Are you determining the ts long value before and then setting it in the Put object? If so, I think you can
> use a specific cell as a counter. In that case of course you need the value of the TS so that's not a problem.

The problem is that I would insert an increment in one column for different inserts along the table.
Every column has a timestamp, but just the "latest" timestamp is important to the client. By latest
I mean the latest when the client contacted the server, of course it will change.

> The latter is problematic because another client may have inserted a version between your put and the get.

Actually this is not an issue in my logic. This will not happen at all. Thus I am concerned with the overhead.

> The former could work but it depends on your applications version semantic.

It usually works, but server clocks can be unsynchronized and lead us into a loss of data scenario.
  
> Is it ok if another client does an update with the same 'version/timestamp'?

Not at all. The important thing is that the client has all data until a specific version, which is the
timestamp of the last insert in the last communication.

Thank you very much for the ideas!

-----Original Message-----
From: saint.ack@gmail.com [mailto:saint.ack@gmail.com] On Behalf Of Stack
Sent: terça-feira, 31 de julho de 2012 18:12
To: user@hbase.apache.org
Subject: Re: Retrieve Put timestamp

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