I suspect you could do what you want in an hbase coprocessor; however you would probably have to take care to play nice with Phoenix. The gist of the coprocessor logic would be if the value matches, incr it; otherwise don't update. Ideally you could throw an Exception and you would get a meaningful SqlException at the client and no adverse effects such as secondary index inconsistencies etc, do the right thing in a transaction, etc.
> On Jul 19, 2016, at 10:11 PM, Josh Elser <[email protected]> wrote: > > Did you read James' response in PHOENIX-2271? [1] > > Restating for you: as a work-around, you could try to use the recent > transaction support which was added via Apache Tephra to prevent multiple > clients from modifying a cell. This would be much less efficient than the > "native" checkAndPut API call from HBase; however, I cannot think of any > other solution which exists in a released version of Apache Phoenix. > > [1] > https://issues.apache.org/jira/browse/PHOENIX-2271?focusedCommentId=14877306&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14877306 > > [email protected] wrote: >> Hi team, >> >> Any pointers/help? >> >> Thanks >> >> Shal >> >> *From:*Sharma, Shalandra: IT (NYK) >> *Sent:* Monday, May 23, 2016 11:25 >> *To:* '[email protected]' >> *Subject:* HBase checkAndPut Support >> >> Hi Team, >> >> We are evaluating use of Phoenix in our project. We are using CDH 5.5.2. >> One of our use cases is to update the HBase row only if the value in a >> column (version) is greater than or equal to the current value. Using >> HBase core APIs we can achieve this by checkAndPut but I could not find >> any similar mechanism via Phoenix. >> >> I have followed the discussion in the following JIRAs and it looks like >> this is something which will be available only in a future release. Can >> you please advise if there is a work around available otherwise it will >> be a blocker for us. >> >> https://issues.apache.org/jira/browse/PHOENIX-2271 >> >> https://issues.apache.org/jira/browse/PHOENIX-2275 >> >> https://issues.apache.org/jira/browse/PHOENIX-2199 >> >> Thanks >> >> *Shalandra Sharma* >> >> _______________________________________________ >> >> This message is for information purposes only, it is not a >> recommendation, advice, offer or solicitation to buy or sell a product >> or service nor an official confirmation of any transaction. It is >> directed at persons who are professionals and is not intended for retail >> customer use. Intended for recipient only. This message is subject to >> the terms at: www.barclays.com/emaildisclaimer >> <http://www.barclays.com/emaildisclaimer>. >> >> For important disclosures, please see: >> www.barclays.com/salesandtradingdisclaimer >> <http://www.barclays.com/salesandtradingdisclaimer> regarding market >> commentary from Barclays Sales and/or Trading, who are active market >> participants; and in respect of Barclays Research, including disclosures >> relating to specific issuers, please see http://publicresearch.barclays.com. >> >> _______________________________________________ >>
