You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hbase.apache.org by Jean-Marc Spaggiari <je...@spaggiari.org> on 2019/03/25 18:54:16 UTC

GetAndPut

Hi all,

We have all CheckAndxxx operations, where we verify something and if the
condition is true we perform the operatoin (Put, Delete, Mutation, etc.).

I'm looking for a GetAndPut operation. Where in a single atomic call, I can
get the actual value of a cell (if any), and perform the put. Working on a
usecase where this might help.

Do we have anything like that? I can simulate by doing a Get then a
CheckAndPut, but that's 2 calls. Trying to save one call ;)

Do we have anything like that?

Thanks

JMS

Re: GetAndPut

Posted by Nick Dimiduk <nd...@gmail.com>.
Hi JM,

I wonder if your usecase is supported by the multi operation. If you enable
multiple cell versions on the store, you should be able to send a single
multi RPC containing first the CAX, then the multi-version get. The get
portion of the returned result would contain all the cell values you
require. (Be advised, this likely remains a source of data-race bugs when
you have multiple clients writing to a cell; I tend to stay away from CAX
operations for this reason.)

However, I’m not sure if multi support for CAX operations was ever
implemented.

Bonne chance,
-n

On Mon, Mar 25, 2019 at 12:23 PM Jean-Marc Spaggiari <
jean-marc@spaggiari.org> wrote:

> Well, I just don't want it to fail. I want to put a value that will replace
> the previous one and just return it (the previous one).
>
> It can be something like:
> repeat until success {
>   Get previous value
>   CheckAndPut(new value, previous value)
> }
> Then I know what I replaced by what.
>
> The usecase is where someone wants to keep track of what has been modified.
> A bit like a client side WAL. But they want that ONLY for updates. They
> don't care about new inserts. And since there is 99% inserts and only 1%
> updates, they don't want to just keep all puts.
>
> JMS
>
> Le lun. 25 mars 2019 à 15:16, Vladimir Rodionov <vl...@gmail.com> a
> écrit :
>
> > Interesting. If CheckAndPut succeeds, then you know the value and no need
> > for Get, right?
> > Only if it fail, you want to know current value if CheckAndPut fails?
> > Can you elaborate on your use case, Jean-Marc?
> >
> > -Vlad
> >
> > On Mon, Mar 25, 2019 at 11:54 AM Jean-Marc Spaggiari <
> > jean-marc@spaggiari.org> wrote:
> >
> > > Hi all,
> > >
> > > We have all CheckAndxxx operations, where we verify something and if
> the
> > > condition is true we perform the operatoin (Put, Delete, Mutation,
> etc.).
> > >
> > > I'm looking for a GetAndPut operation. Where in a single atomic call, I
> > can
> > > get the actual value of a cell (if any), and perform the put. Working
> on
> > a
> > > usecase where this might help.
> > >
> > > Do we have anything like that? I can simulate by doing a Get then a
> > > CheckAndPut, but that's 2 calls. Trying to save one call ;)
> > >
> > > Do we have anything like that?
> > >
> > > Thanks
> > >
> > > JMS
> > >
> >
>

Re: GetAndPut

Posted by Jean-Marc Spaggiari <je...@spaggiari.org>.
Well, I just don't want it to fail. I want to put a value that will replace
the previous one and just return it (the previous one).

It can be something like:
repeat until success {
  Get previous value
  CheckAndPut(new value, previous value)
}
Then I know what I replaced by what.

The usecase is where someone wants to keep track of what has been modified.
A bit like a client side WAL. But they want that ONLY for updates. They
don't care about new inserts. And since there is 99% inserts and only 1%
updates, they don't want to just keep all puts.

JMS

Le lun. 25 mars 2019 à 15:16, Vladimir Rodionov <vl...@gmail.com> a
écrit :

> Interesting. If CheckAndPut succeeds, then you know the value and no need
> for Get, right?
> Only if it fail, you want to know current value if CheckAndPut fails?
> Can you elaborate on your use case, Jean-Marc?
>
> -Vlad
>
> On Mon, Mar 25, 2019 at 11:54 AM Jean-Marc Spaggiari <
> jean-marc@spaggiari.org> wrote:
>
> > Hi all,
> >
> > We have all CheckAndxxx operations, where we verify something and if the
> > condition is true we perform the operatoin (Put, Delete, Mutation, etc.).
> >
> > I'm looking for a GetAndPut operation. Where in a single atomic call, I
> can
> > get the actual value of a cell (if any), and perform the put. Working on
> a
> > usecase where this might help.
> >
> > Do we have anything like that? I can simulate by doing a Get then a
> > CheckAndPut, but that's 2 calls. Trying to save one call ;)
> >
> > Do we have anything like that?
> >
> > Thanks
> >
> > JMS
> >
>

Re: GetAndPut

Posted by Vladimir Rodionov <vl...@gmail.com>.
Interesting. If CheckAndPut succeeds, then you know the value and no need
for Get, right?
Only if it fail, you want to know current value if CheckAndPut fails?
Can you elaborate on your use case, Jean-Marc?

-Vlad

On Mon, Mar 25, 2019 at 11:54 AM Jean-Marc Spaggiari <
jean-marc@spaggiari.org> wrote:

> Hi all,
>
> We have all CheckAndxxx operations, where we verify something and if the
> condition is true we perform the operatoin (Put, Delete, Mutation, etc.).
>
> I'm looking for a GetAndPut operation. Where in a single atomic call, I can
> get the actual value of a cell (if any), and perform the put. Working on a
> usecase where this might help.
>
> Do we have anything like that? I can simulate by doing a Get then a
> CheckAndPut, but that's 2 calls. Trying to save one call ;)
>
> Do we have anything like that?
>
> Thanks
>
> JMS
>