You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Patrik Modesto <pa...@gmail.com> on 2012/06/25 09:06:20 UTC

Removing a counter columns using Thrift interface

Hi,

I was playing with Counters in Cassandra 1.0.10 and I see a behaviour
that I didn't expect. It's about removing a Counter column.

I'm used to use Mutation for everything, so the first thing I tried
was Deletion on Counter column. Well, nothing happened. No error and
the Counter column was still there.

The second try was the remove_counter() method. When I set just the
column_family of ColumnPath, nothing happened. No error and the
Counter column was still there. I supposed it would work like the
remove() method which would remove whole row.

The third try was the remove_counter() method with fully specified
Counter column in ColumnPath. Now the Counter column was gone.

Maybe it behaves differenrtly in 1.1.x version but I'd expect working
Deletion() on Counter column or error and remove_counter() to work
like remove().

Why did I try to remove a Counter column? Because I need to reset the
counter to zero before computing something and I don't know other way.
 Suppose I have thousands of countes I need to reset and I don't want
to read every Counter column I need to reset and then to all of them
write their negative value.

Regards,
Patrik

Re: Removing a counter columns using Thrift interface

Posted by Patrik Modesto <pa...@gmail.com>.
On Mon, Jun 25, 2012 at 9:28 AM, Sylvain Lebresne <sy...@datastax.com> wrote:
> On Mon, Jun 25, 2012 at 9:06 AM, Patrik Modesto
> <pa...@gmail.com> wrote:
>> I'm used to use Mutation for everything, so the first thing I tried
>> was Deletion on Counter column. Well, nothing happened. No error and
>> the Counter column was still there.
>
> That shouldn't happen.
>
>> The second try was the remove_counter() method. When I set just the
>> column_family of ColumnPath, nothing happened. No error and the
>> Counter column was still there. I supposed it would work like the
>> remove() method which would remove whole row.
>
> It should. If if it doesn't that would be a bug. If you can reproduce
> such a bug, then please do open a ticket.

I've tried again today and found one bug in my test program. Now
Deletion works as expected. The remove_counter() works as well, I
misinterpreted the results.

Regards,
P.

Re: Removing a counter columns using Thrift interface

Posted by Sylvain Lebresne <sy...@datastax.com>.
On Mon, Jun 25, 2012 at 9:06 AM, Patrik Modesto
<pa...@gmail.com> wrote:
> I'm used to use Mutation for everything, so the first thing I tried
> was Deletion on Counter column. Well, nothing happened. No error and
> the Counter column was still there.

That shouldn't happen.

> The second try was the remove_counter() method. When I set just the
> column_family of ColumnPath, nothing happened. No error and the
> Counter column was still there. I supposed it would work like the
> remove() method which would remove whole row.

It should. If if it doesn't that would be a bug. If you can reproduce
such a bug, then please do open a ticket.

> Why did I try to remove a Counter column? Because I need to reset the
> counter to zero before computing something and I don't know other way.

Unfortunately that will not work. As said here:
http://wiki.apache.org/cassandra/Counters,
the removal of counters if limited and cannot be used to reset a counter.
That is, deleting a counter should work, but incrementing the same
counter afterwards will not produce the expected result.
I'll note that this is a limitation of the counter design, and as such I don't
expect this to be fixed any time soon so you do will have to work around
it.

--
Sylvain