#5633 was actually closed  because the static columns feature (
https://issues.apache.org/jira/browse/CASSANDRA-6561) which has been
checked in to the 2.0 branch but is not yet part of a release (it will be
in 2.0.6).

That feature will let you update multiple rows within a single partition by
doing a CAS write based on a static column shared by all rows within the
partition.

Example extracted from the ticket:
CREATE TABLE foo (
    x text,
    y bigint,
    t bigint static,
    z bigint,
PRIMARY KEY (x, y) );

insert into foo (x,y,t, z) values ('a', 1, 1, 10);
insert into foo (x,y,t, z) values ('a', 2, 2, 20);

select * from foo;

x | y | t | z
---+---+---+----
 a | 1 | 2 | 10
 a | 2 | 2 | 20
(Note that both values of "t" are 2 because it is static)


 begin batch update foo set z = 1 where x = 'a' and y = 1; update foo set z
= 2 where x = 'a' and y = 2 if t = 4; apply batch;

 [applied] | x | y    | t
-----------+---+------+---
     False | a | null | 2

(Both updates failed to apply because there was an unmet conditional on one
of them)

select * from foo;

 x | y | t | z
---+---+---+----
 a | 1 | 2 | 10
 a | 2 | 2 | 20


begin batch update foo set z = 1 where x = 'a' and y = 1; update foo set z
= 2 where x = 'a' and y = 2 if t = 2; apply batch;

 [applied]
-----------
      True

(both updates succeeded because the check on t succeeded)

select * from foo;
x | y | t | z
---+---+---+---
 a | 1 | 2 | 1
 a | 2 | 2 | 2

Hope this helps.

-Tupshin



On Fri, Feb 21, 2014 at 6:05 PM, DuyHai Doan <doanduy...@gmail.com> wrote:

> Hello Clint
>
>  The Resolution status of the JIRA is set to "Later", probably the
> implementation is not done yet. The JIRA was opened to discuss about impl
> strategy but nothing has been coded so far I guess.
>
>
>
> On Sat, Feb 22, 2014 at 12:02 AM, Clint Kelly <clint.ke...@gmail.com>wrote:
>
>> Folks,
>>
>> Does anyone know how I can modify multiple rows at once in a
>> lightweight transaction in CQL3?
>>
>> I saw the following ticket:
>>
>>     https://issues.apache.org/jira/browse/CASSANDRA-5633
>>
>> but it was not obvious to me from the comments how (or whether) this
>> got resolved.  I also couldn't find anything in the DataStax
>> documentation about how to perform these operations.
>>
>> I'm in particular interested in how to perform a compare-and-set
>> operation that modifies multiple rows (with the same partition key)
>> using the DataStax Java driver.
>>
>> Thanks!
>>
>> Best regards,
>> Clint
>>
>
>

Reply via email to