[ 
https://issues.apache.org/jira/browse/PHOENIX-2909?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

James Taylor updated PHOENIX-2909:
----------------------------------
    Description: 
We can surface atomic checkAndPut like functionality through support of the SQL 
UPSERT statement.

For example, the following could use do a get under row lock to perform the row 
update atomically
{code}
UPDATE  my_table SET counter=coalesce(counter + 1,0) FROM my_table;
{code}

To force prior MVCC transactions to complete (making it serializable as an 
Increment is), we'd have code like this:
{code}
    mvcc = region.getMVCC();
    mvcc.completeMemstoreInsert(mvcc.beginMemstoreInsert());
{code}

By users setting auto commit to true and issuing an UPDATE statement over a non 
transactional table, they'd get a way for row updates to be atomic. This would 
work especially well to support counters.

  was:
We could potentially recognize updates to the same column in a SQL statement 
and compile them into either a check and put or increment call.

For example, the following could use increment or a get/put under row lock to 
perform the row update atomically
{code}
UPSERT INTO my_table(pk1, pk2, counter) SELECT pk1, pk2, counter + 1 FROM 
my_table;
{code}


> Surface checkAndPut through UPDATE support
> ------------------------------------------
>
>                 Key: PHOENIX-2909
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2909
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: James Taylor
>
> We can surface atomic checkAndPut like functionality through support of the 
> SQL UPSERT statement.
> For example, the following could use do a get under row lock to perform the 
> row update atomically
> {code}
> UPDATE  my_table SET counter=coalesce(counter + 1,0) FROM my_table;
> {code}
> To force prior MVCC transactions to complete (making it serializable as an 
> Increment is), we'd have code like this:
> {code}
>     mvcc = region.getMVCC();
>     mvcc.completeMemstoreInsert(mvcc.beginMemstoreInsert());
> {code}
> By users setting auto commit to true and issuing an UPDATE statement over a 
> non transactional table, they'd get a way for row updates to be atomic. This 
> would work especially well to support counters.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to