The only way to do this in Cassandra now is with counters - whether you add 1 
or n, it's counters or ugly read before write and lightweight transactions. 
Counters give Cassandra the closest thing they'll ever have to vector clocks - 
they give the user a way to do commutative deltas in a distributed system with 
all the hard work handled for you. 

In a world without counters, think about a situation like this - 

Imagine you have 6 nodes - 3 in each data center 

You insert a row with key=jeff into one DC (dc1)

The data centers are disconnected due to an ISP failure

You run "set value=value+1 where name='jeff'" in dc1

You run "set value=value+1 where name='jeff'" in dc2 - what happens?

What's the value when the data centers reconnect? 

Counters handle this for you - they aren't perfect, but they're better than 
most people would do independently at the application level. 

-- 
Jeff Jirsa


> On Oct 17, 2016, at 6:44 PM, Kant Kodali <k...@peernova.com> wrote:
> 
> How about “Set the value 1 above what it is now" ? The same principle should 
> apply right?
> 
> 
> 
> 
>> On Mon, Oct 17, 2016 at 6:21 PM, Jeff Jirsa <jeff.ji...@crowdstrike.com> 
>> wrote:
>> You cant use int/bigint to say “Set the value 2 above what it is now”, 
>> unless you use a read to get the current value, then write using lightweight 
>> transactions, which have a significant performance penalty.
>> 
>>  
>> 
>> The primary reason for this is because no individual Cassandra node is 
>> guaranteed to know the current state of any cell at the time the write 
>> arrives – counters attempt to solve this
>> 
>>  
>> 
>>  
>> 
>>  
>> 
>>  
>> 
>> From: Kant Kodali <k...@peernova.com>
>> Reply-To: "user@cassandra.apache.org" <user@cassandra.apache.org>
>> Date: Monday, October 17, 2016 at 5:20 PM
>> To: "user@cassandra.apache.org" <user@cassandra.apache.org>
>> Subject: What is the point of counter type when we can do the same thing 
>> with int or bigint?
>> 
>>  
>> 
>> I just read the following link 
>> 
>>  
>> 
>> https://docs.datastax.com/en/cql/3.3/cql/cql_using/useCounters.html
>> 
>>  
>> 
>>  
>> 
>> and I wonder what is the point of counter type when we can do the same thing 
>> with int or bigint? what are benefits of using counter data type?
>> 
>>  
>> 
>>  
>> 
>> ____________________________________________________________________
>> CONFIDENTIALITY NOTE: This e-mail and any attachments are confidential and 
>> may be legally privileged. If you are not the intended recipient, do not 
>> disclose, copy, distribute, or use this email or any attachments. If you 
>> have received this in error please let the sender know and then delete the 
>> email and all attachments.
> 

____________________________________________________________________
CONFIDENTIALITY NOTE: This e-mail and any attachments are confidential and may 
be legally privileged. If you are not the intended recipient, do not disclose, 
copy, distribute, or use this email or any attachments. If you have received 
this in error please let the sender know and then delete the email and all 
attachments.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to