You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by sagar naik <sn...@attributor.com> on 2011/09/15 04:00:06 UTC
update/increment only if row is present
Hello Friends,
We have a case in our application where we need to update values or
increment values only if the row is present.
Primary reason being, row key received may be corrupt or invalid. We dont
want to create dangling rows.
Obviously,
- get row key and check if the row exists, then update is a costly call. 2
round trips for each update
- checkAndPut -> one needs to knw row,family,qualifer and value to
accomplish this. I initially thought passing just rowkey and value=rowKey
will work. But, u need all the arguments.
- Is there any hack u can recommend to work around this problem.
- Also, for increment, how do I implement it.
In short, any update/increment should happen only if row key is present. So
this will help me achieve some data integrity
Thanks
The community is super helpful
So Thanks again :)
-Sagar
Re: update/increment only if row is present
Posted by Jean-Daniel Cryans <jd...@apache.org>.
You can implement anything you want :) Contributing back is another story.
So if you can't predict the value of a single column, see my other
recommendation.
J-D
On Thu, Sep 15, 2011 at 5:04 PM, sagar naik <sn...@attributor.com> wrote:
> Thanks J-D
>
> On Thu, Sep 15, 2011 at 4:15 PM, Jean-Daniel Cryans <jd...@apache.org>wrote:
>
>> For checkAndPut, is there a column that you know will exist that
>> you're not updating that you know for sure which value it will have?
>> Worst case you could use a dummy column just for that.
>>
>> Column data is not predictable
> Can I implement this functionality on the lines of checkAndPut , calling it
> updateOnlyIfRowExists () ,
>
>
>> For increments, I can't think of a way to do it without either
>> implementing a checkAndIncrement or doing 2 roundtrips.
>>
>>
>
>
>> J-D
>>
>
>
> -Sagar
>
>>
>> On Wed, Sep 14, 2011 at 7:00 PM, sagar naik <sn...@attributor.com> wrote:
>> > Hello Friends,
>> >
>> > We have a case in our application where we need to update values or
>> > increment values only if the row is present.
>> > Primary reason being, row key received may be corrupt or invalid. We dont
>> > want to create dangling rows.
>> >
>> > Obviously,
>> > - get row key and check if the row exists, then update is a costly call.
>> 2
>> > round trips for each update
>> > - checkAndPut -> one needs to knw row,family,qualifer and value to
>> > accomplish this. I initially thought passing just rowkey and value=rowKey
>> > will work. But, u need all the arguments.
>> > - Is there any hack u can recommend to work around this problem.
>> > - Also, for increment, how do I implement it.
>> >
>> > In short, any update/increment should happen only if row key is present.
>> So
>> > this will help me achieve some data integrity
>> >
>> >
>> > Thanks
>> > The community is super helpful
>> > So Thanks again :)
>> >
>> > -Sagar
>> >
>>
>
Re: update/increment only if row is present
Posted by sagar naik <sn...@attributor.com>.
Thanks J-D
On Thu, Sep 15, 2011 at 4:15 PM, Jean-Daniel Cryans <jd...@apache.org>wrote:
> For checkAndPut, is there a column that you know will exist that
> you're not updating that you know for sure which value it will have?
> Worst case you could use a dummy column just for that.
>
> Column data is not predictable
Can I implement this functionality on the lines of checkAndPut , calling it
updateOnlyIfRowExists () ,
> For increments, I can't think of a way to do it without either
> implementing a checkAndIncrement or doing 2 roundtrips.
>
>
> J-D
>
-Sagar
>
> On Wed, Sep 14, 2011 at 7:00 PM, sagar naik <sn...@attributor.com> wrote:
> > Hello Friends,
> >
> > We have a case in our application where we need to update values or
> > increment values only if the row is present.
> > Primary reason being, row key received may be corrupt or invalid. We dont
> > want to create dangling rows.
> >
> > Obviously,
> > - get row key and check if the row exists, then update is a costly call.
> 2
> > round trips for each update
> > - checkAndPut -> one needs to knw row,family,qualifer and value to
> > accomplish this. I initially thought passing just rowkey and value=rowKey
> > will work. But, u need all the arguments.
> > - Is there any hack u can recommend to work around this problem.
> > - Also, for increment, how do I implement it.
> >
> > In short, any update/increment should happen only if row key is present.
> So
> > this will help me achieve some data integrity
> >
> >
> > Thanks
> > The community is super helpful
> > So Thanks again :)
> >
> > -Sagar
> >
>
Re: update/increment only if row is present
Posted by Jean-Daniel Cryans <jd...@apache.org>.
For checkAndPut, is there a column that you know will exist that
you're not updating that you know for sure which value it will have?
Worst case you could use a dummy column just for that.
For increments, I can't think of a way to do it without either
implementing a checkAndIncrement or doing 2 roundtrips.
J-D
On Wed, Sep 14, 2011 at 7:00 PM, sagar naik <sn...@attributor.com> wrote:
> Hello Friends,
>
> We have a case in our application where we need to update values or
> increment values only if the row is present.
> Primary reason being, row key received may be corrupt or invalid. We dont
> want to create dangling rows.
>
> Obviously,
> - get row key and check if the row exists, then update is a costly call. 2
> round trips for each update
> - checkAndPut -> one needs to knw row,family,qualifer and value to
> accomplish this. I initially thought passing just rowkey and value=rowKey
> will work. But, u need all the arguments.
> - Is there any hack u can recommend to work around this problem.
> - Also, for increment, how do I implement it.
>
> In short, any update/increment should happen only if row key is present. So
> this will help me achieve some data integrity
>
>
> Thanks
> The community is super helpful
> So Thanks again :)
>
> -Sagar
>