You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Clint Kelly <cl...@gmail.com> on 2014/03/01 01:32:48 UTC

Resetting a counter in CQL

Folks,

What is the best known method for resetting a counter in CQL?  Is it best
to read the counter and then increment it by a negative amount?  Or to
delete the row and then increment it by zero?

These are the two methods I could come up with.  Both of these seem fine to
me---I'm just wondering if there is a standard way to do this.  Thanks!

Best regards,
Clint

Re: Resetting a counter in CQL

Posted by Clint Kelly <cl...@gmail.com>.
Great, thanks!


On Fri, Feb 28, 2014 at 4:38 PM, Tyler Hobbs <ty...@datastax.com> wrote:

>
> On Fri, Feb 28, 2014 at 6:32 PM, Clint Kelly <cl...@gmail.com>wrote:
>
>>
>>
>> What is the best known method for resetting a counter in CQL?  Is it best
>> to read the counter and then increment it by a negative amount?
>
>
> Do this.
>
>
>>   Or to delete the row and then increment it by zero?
>>
>
> Don't do this.  When you delete a counter, you are basically saying "I
> will never use this counter again".  If you try to use it again, the
> behavior is undefined. It's one of the documented limitations of counters.
>
>
> --
> Tyler Hobbs
> DataStax <http://datastax.com/>
>

Re: Resetting a counter in CQL

Posted by Tyler Hobbs <ty...@datastax.com>.
On Fri, Feb 28, 2014 at 6:32 PM, Clint Kelly <cl...@gmail.com> wrote:

>
>
> What is the best known method for resetting a counter in CQL?  Is it best
> to read the counter and then increment it by a negative amount?


Do this.


>   Or to delete the row and then increment it by zero?
>

Don't do this.  When you delete a counter, you are basically saying "I will
never use this counter again".  If you try to use it again, the behavior is
undefined. It's one of the documented limitations of counters.


-- 
Tyler Hobbs
DataStax <http://datastax.com/>

Re: Resetting a counter in CQL

Posted by Clint Kelly <cl...@gmail.com>.
Hi Tupshin,

Will the new implementation of counters in 2.1 still use the same CQL
commands as the current implementation?

Thanks!

Best regards,
Clint


On Sat, Mar 1, 2014 at 2:34 PM, Tupshin Harper <tu...@tupshin.com> wrote:

> The complete rewrite of counters in 2.1(which should address the counter
> accuracy issues) will still have this limitation.  Deleting and recreating
> counters is not supported and will continue to not be supported.
>
> -Tupshin
> On Mar 1, 2014 5:13 PM, "Manoj Khangaonkar" <kh...@gmail.com> wrote:
>
>> The last time I checked as in v 2.0.0 counters did not work. Over a
>> period of time , the counters drift from the correct value. There were
>> several open issues and proposal to rewrite the counter implementation
>>
>> Have you checked if all the issues with counters have been fixed ?
>>
>> regards
>>
>>
>> On Fri, Feb 28, 2014 at 4:32 PM, Clint Kelly <cl...@gmail.com>wrote:
>>
>>> Folks,
>>>
>>> What is the best known method for resetting a counter in CQL?  Is it
>>> best to read the counter and then increment it by a negative amount?  Or to
>>> delete the row and then increment it by zero?
>>>
>>> These are the two methods I could come up with.  Both of these seem fine
>>> to me---I'm just wondering if there is a standard way to do this.  Thanks!
>>>
>>> Best regards,
>>> Clint
>>>
>>
>>
>>
>> --
>> http://khangaonkar.blogspot.com/
>>
>

Re: Resetting a counter in CQL

Posted by Clint Kelly <cl...@gmail.com>.
Thanks everyone for the responses!

I observed today also some issues if I tried to delete a counter and then
increment it again.  I expected incrementing a deleted counter would result
in the same behavior as incrementing an uninitialized counter, but the
value was stuck at 'null' after the delete and subsequent increments.

Thanks for clarifying that this is the expected behavior!

Best regards,
Clint


On Sat, Mar 1, 2014 at 3:53 PM, Edward Capriolo <ed...@gmail.com>wrote:

> If you want super accurate "counters" a good option available is to to
> batching on the client side and then take advantage of CAS. For now
> counters for smaller windows of time (think minute not days) should help
> with some drift issues.
>
>
> On Sat, Mar 1, 2014 at 5:34 PM, Tupshin Harper <tu...@tupshin.com>wrote:
>
>> The complete rewrite of counters in 2.1(which should address the counter
>> accuracy issues) will still have this limitation.  Deleting and recreating
>> counters is not supported and will continue to not be supported.
>>
>> -Tupshin
>> On Mar 1, 2014 5:13 PM, "Manoj Khangaonkar" <kh...@gmail.com>
>> wrote:
>>
>>> The last time I checked as in v 2.0.0 counters did not work. Over a
>>> period of time , the counters drift from the correct value. There were
>>> several open issues and proposal to rewrite the counter implementation
>>>
>>> Have you checked if all the issues with counters have been fixed ?
>>>
>>> regards
>>>
>>>
>>> On Fri, Feb 28, 2014 at 4:32 PM, Clint Kelly <cl...@gmail.com>wrote:
>>>
>>>> Folks,
>>>>
>>>> What is the best known method for resetting a counter in CQL?  Is it
>>>> best to read the counter and then increment it by a negative amount?  Or to
>>>> delete the row and then increment it by zero?
>>>>
>>>> These are the two methods I could come up with.  Both of these seem
>>>> fine to me---I'm just wondering if there is a standard way to do this.
>>>> Thanks!
>>>>
>>>> Best regards,
>>>> Clint
>>>>
>>>
>>>
>>>
>>> --
>>> http://khangaonkar.blogspot.com/
>>>
>>
>

Re: Resetting a counter in CQL

Posted by Edward Capriolo <ed...@gmail.com>.
If you want super accurate "counters" a good option available is to to
batching on the client side and then take advantage of CAS. For now
counters for smaller windows of time (think minute not days) should help
with some drift issues.


On Sat, Mar 1, 2014 at 5:34 PM, Tupshin Harper <tu...@tupshin.com> wrote:

> The complete rewrite of counters in 2.1(which should address the counter
> accuracy issues) will still have this limitation.  Deleting and recreating
> counters is not supported and will continue to not be supported.
>
> -Tupshin
> On Mar 1, 2014 5:13 PM, "Manoj Khangaonkar" <kh...@gmail.com> wrote:
>
>> The last time I checked as in v 2.0.0 counters did not work. Over a
>> period of time , the counters drift from the correct value. There were
>> several open issues and proposal to rewrite the counter implementation
>>
>> Have you checked if all the issues with counters have been fixed ?
>>
>> regards
>>
>>
>> On Fri, Feb 28, 2014 at 4:32 PM, Clint Kelly <cl...@gmail.com>wrote:
>>
>>> Folks,
>>>
>>> What is the best known method for resetting a counter in CQL?  Is it
>>> best to read the counter and then increment it by a negative amount?  Or to
>>> delete the row and then increment it by zero?
>>>
>>> These are the two methods I could come up with.  Both of these seem fine
>>> to me---I'm just wondering if there is a standard way to do this.  Thanks!
>>>
>>> Best regards,
>>> Clint
>>>
>>
>>
>>
>> --
>> http://khangaonkar.blogspot.com/
>>
>

Re: Resetting a counter in CQL

Posted by Tupshin Harper <tu...@tupshin.com>.
The complete rewrite of counters in 2.1(which should address the counter
accuracy issues) will still have this limitation.  Deleting and recreating
counters is not supported and will continue to not be supported.

-Tupshin
On Mar 1, 2014 5:13 PM, "Manoj Khangaonkar" <kh...@gmail.com> wrote:

> The last time I checked as in v 2.0.0 counters did not work. Over a period
> of time , the counters drift from the correct value. There were several
> open issues and proposal to rewrite the counter implementation
>
> Have you checked if all the issues with counters have been fixed ?
>
> regards
>
>
> On Fri, Feb 28, 2014 at 4:32 PM, Clint Kelly <cl...@gmail.com>wrote:
>
>> Folks,
>>
>> What is the best known method for resetting a counter in CQL?  Is it best
>> to read the counter and then increment it by a negative amount?  Or to
>> delete the row and then increment it by zero?
>>
>> These are the two methods I could come up with.  Both of these seem fine
>> to me---I'm just wondering if there is a standard way to do this.  Thanks!
>>
>> Best regards,
>> Clint
>>
>
>
>
> --
> http://khangaonkar.blogspot.com/
>

Re: Resetting a counter in CQL

Posted by Manoj Khangaonkar <kh...@gmail.com>.
The last time I checked as in v 2.0.0 counters did not work. Over a period
of time , the counters drift from the correct value. There were several
open issues and proposal to rewrite the counter implementation

Have you checked if all the issues with counters have been fixed ?

regards


On Fri, Feb 28, 2014 at 4:32 PM, Clint Kelly <cl...@gmail.com> wrote:

> Folks,
>
> What is the best known method for resetting a counter in CQL?  Is it best
> to read the counter and then increment it by a negative amount?  Or to
> delete the row and then increment it by zero?
>
> These are the two methods I could come up with.  Both of these seem fine
> to me---I'm just wondering if there is a standard way to do this.  Thanks!
>
> Best regards,
> Clint
>



-- 
http://khangaonkar.blogspot.com/