Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase >> mail # user >> How to implement this check put and then update something logic?

Copy link to this message
RE: How to implement this check put and then update something logic?
Well, this did come from a graph domain.

However, I think this could be a common problem when you need to update something according to the original value where a simple checkAndPut on single value won't work.

Another example, if you want to implement something like UPDATE, you want to know whether this is a new value inserted, or update to an old value. It won't be easy now,
You need to checkAndPut on null, if not null, then you get the value and checkAndPut on that value, since you want to make sure the column is still there. If it fails , you loop back from check null.

So I think a little bit of enhancement on current HBASE atomic operation could greatly improve the usability upon similar problems. Or maybe there are already solution for this type of issue?

> Maybe this problem is more in the graph domain? I know that there are
> projects aimed at representing graphs at large scale better. I'm saying this
> since you have one ID referencing another ID (using target ID).
> On May 10, 2013, at 11:47 AM, "Liu, Raymond" <[EMAIL PROTECTED]>
> wrote:
> > Thanks, seems there are no other better solution?
> >
> > Really need a "GetAndPut" atomic op here ...
> >
> >>
> >> You can do this by looping over a checkAndPut operation until it succeeds.
> >>
> >> -Mike
> >>
> >> On Thu, May 9, 2013 at 8:52 PM, Liu, Raymond <[EMAIL PROTECTED]>
> >> wrote:
> >>> Any suggestion?
> >>>
> >>>>
> >>>> Hi
> >>>>
> >>>>      Say, I have four field for one record :id, status, targetid, and count.
> >>>>      Status is on and off, target could reference other id, and
> >>>> count will record the number of "on" status for all targetid from same id.
> >>>>
> >>>>      The record could be add / delete, or updated to change the status.
> >>>>
> >>>>      I could put count in another table, or put it in the same
> >>>> table, it doesn't matter. As long as it can work.
> >>>>
> >>>>      My question is how can I ensure its correctness of the "count"
> >>>> field when run with multiple client update the table concurrently?
> >>>>
> >>>>      The closet thing I can think of is checkAndPut, but I will
> >>>> need two steps to find out the change of count, since checkAndPut
> >>>> etc can only test a single value and with EQUAL comparator, thus I
> >>>> can only check upon null firstly, then on or off. Thus when thing
> >>>> change during this two step, I need to retry from first step until
> >>>> it succeed. This
> >> could be bad when a lot of concurrent op is on going.
> >>>>
> >>>>      And then, I need to update count by checkAndIncrement, though
> >>>> if the above problem could be solved, the order of -1 +1 might not
> >>>> be important for the final result, but in some intermediate time,
> >>>> it might not reflect the real count of that time.
> >>>>
> >>>>      I know this kind of transaction is not the target of HBASE,
> >>>> APP should take care of it, then , what's the best practice on
> >>>> this? Any quick simple solution for my problem? Client RowLock
> >>>> could solve this issue, But it seems to me that it is not safe and
> >>>> is not recommended and
> >> deprecated?
> >>>>
> >>>>      Btw. Is that possible or practice to implement something like
> >>>> PutAndGet which put in new row and return the old row back to
> >>>> client been
> >> implemented?
> >>>> That would help a lot for my case.
> >>>>
> >>>> Best Regards,
> >>>> Raymond Liu
> >>>