One should never* call lockRow(), and prefer to do something else
instead. CheckAndPut works like CompareAndSet (we just call it Put
since that is what you are doing in our API, putting), and there is
also the incrementColumnValue() call.
I'm not really following your code (I'm also sick), but why not just
do something like this:
- Table: Sequences
rowid: table_name column: id value: sequence
So you just call:
table.incrementColumnValue("Sequences",
tableNameThatYouWantSequenceFor, "id", 1);
and the result is your sequence id to use as a primary key. No need
to worry about non-existant values, the call creates the value, so the
sequence starts at 1 always.
-ryan
* ok you can call lockRow, but be aware that your milage may vary, you
reduce the performance of HBase, and generally can cause a lot of
problems. Eg: you can DOS yourself!
On Tue, Oct 19, 2010 at 12:39 PM, tsuna <[email protected]> wrote:
> I would like to add that you can probably get rid of RowLock and use
> checkAndPut instead to atomically create the row if it doesn't already
> exist. This would probably solve the last problem I outlined where 2
> different instances of your web service attempt to assign the same ID
> at the same time. The code would also be simpler and more efficient.
>
> --
> Benoit "tsuna" Sigoure
> Software Engineer @ www.StumbleUpon.com
>