You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Moses Dinakaran <mo...@gmail.com> on 2010/07/06 14:41:55 UTC

Query on delete a column inside a super column

Hi All,

I have a query related to deleting a column inside a super column

The following is my cassandra schema

[cache_pages_key_hash] => Array
        (
            [hash_1] => Array
                (
                    [1] => 4c330e95195f9
                    [2] => 4c330e951f18b
                    [3] => 4c330e9521f3d
                )

        )


No I wanted to remove the index [1] => 4c330e95195f9 from the
supercolumn [hash_1]

Through phpCassa I am doing the following

$updatedRecord   =  array("hash_1" => Array
                                (
                                    2 => "4c330e951f18b"
                                    3 => "4c330e9521f3d"
                               )
                             )


$cassandraInstance->insert('cache_pages_key_hash',$updateRecord );

But while I fetch the record again

I was getting the original records ie the column 1 is not removed from


[cache_pages_key_hash] => Array
        (
            [hash_1] => Array
                (
                    [1] => 4c330e95195f9
                    [2] => 4c330e951f18b
                    [3] => 4c330e9521f3d
                )

        )


But at the same time If I am updating the index 1

ie
$updateRecord   =  array("hash_1" => Array
                                (
                                   1  => ' able to update'
                                    2 => "4c330e951f18b"
                                    3 => "4c330e9521f3d"
                               )
                             )

$cassandraInstance->insert('cache_pages_key_hash',$updateRecord );

The records is being updated, Only problem is that  deleting dosent happens.

My question is that is this behavior is expected as explained in the article
Distributed deletes in the Cassandra database
http://spyced.blogspot.com/2010/02/distributed-deletes-in-cassandra.html

or I am doing wrong.


Thanks,
Moses.

SV: Query on delete a column inside a super column

Posted by Thorvaldsson Justus <ju...@svenskaspel.se>.
This is my first email, just started with Cassandra, I think you want to use Mutate object or something like it "The Mutation object can also be used to create new Columns or to delete a Column, if you supply it with a key that doesn't exist in the database it will create it, if it detects that the key already exists it will overwrite the value and the timestamp. " from a java tutorial on Cassandra. I may be wrong but thought I could try to help.

Regards
Justus

Från: Moses Dinakaran [mailto:mosesdinakaran@gmail.com]
Skickat: den 7 juli 2010 08:51
Till: user@cassandra.apache.org
Ämne: Re: Query on delete a column inside a super column

Hi,

Thanks for the reply,

The remove method
$cassandraInstance->remove('cache_pages_key_hash', 'hash_1' )

which will remove the whole key, But I don't want to do that, I need to remove one column inside that key

Can you please tell me how to use the remove method in this case.


Regards,
Moses.

On Wed, Jul 7, 2010 at 12:16 AM, Jonathan Ellis <jb...@gmail.com>> wrote:
insert is insert-or-update.  leaving out a column from an update
doesn't delete it, you need to use the remove method for that.

On Tue, Jul 6, 2010 at 7:41 AM, Moses Dinakaran
<mo...@gmail.com>> wrote:
> Hi All,
>
> I have a query related to deleting a column inside a super column
>
> The following is my cassandra schema
>
> [cache_pages_key_hash] => Array
>        (
>            [hash_1] => Array
>                (
>                    [1] => 4c330e95195f9
>                    [2] => 4c330e951f18b
>                    [3] => 4c330e9521f3d
>                )
>
>        )
>
>
> No I wanted to remove the index [1] => 4c330e95195f9 from the
> supercolumn [hash_1]
>
> Through phpCassa I am doing the following
>
> $updatedRecord   =  array("hash_1" => Array
>                                (
>                                    2 => "4c330e951f18b"
>                                    3 => "4c330e9521f3d"
>                               )
>                             )
>
>
> $cassandraInstance->insert('cache_pages_key_hash',$updateRecord );
>
> But while I fetch the record again
>
> I was getting the original records ie the column 1 is not removed from
>
>
> [cache_pages_key_hash] => Array
>        (
>            [hash_1] => Array
>                (
>                    [1] => 4c330e95195f9
>                    [2] => 4c330e951f18b
>                    [3] => 4c330e9521f3d
>                )
>
>        )
>
>
> But at the same time If I am updating the index 1
>
> ie
> $updateRecord   =  array("hash_1" => Array
>                                (
>                                   1  => ' able to update'
>                                    2 => "4c330e951f18b"
>                                    3 => "4c330e9521f3d"
>                               )
>                             )
>
> $cassandraInstance->insert('cache_pages_key_hash',$updateRecord );
>
> The records is being updated, Only problem is that  deleting dosent happens.
>
> My question is that is this behavior is expected as explained in the article
> Distributed deletes in the Cassandra database
> http://spyced.blogspot.com/2010/02/distributed-deletes-in-cassandra.html
>
> or I am doing wrong.
>
>
> Thanks,
> Moses.
>


--
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of Riptano, the source for professional Cassandra support
http://riptano.com


Re: Query on delete a column inside a super column

Posted by Moses Dinakaran <mo...@gmail.com>.
As per my knowledge in phpCassa I didnt find any option to remove a
column from the supercolumn, The remove method removes the whole super
column from the key, will check with thrift api.

Through mutation object insert/update happens but removing a column
dosent happen.

Thank you all.

Regards
Moses.


On Wed, Jul 7, 2010 at 7:41 PM, Jonathan Ellis <jb...@gmail.com> wrote:
>
> the thrift api allows you to optionally specify column and subcolumn
> as well.  no idea how or if phpCassa exposes this though.
>
> On Wed, Jul 7, 2010 at 1:51 AM, Moses Dinakaran
> <mo...@gmail.com> wrote:
> > Hi,
> >
> > Thanks for the reply,
> >
> > The remove method
> > $cassandraInstance->remove('cache_pages_key_hash', 'hash_1' )
> >
> > which will remove the whole key, But I don't want to do that, I need to
> > remove one column inside that key
> >
> > Can you please tell me how to use the remove method in this case.
> >
> >
> > Regards,
> > Moses.
> >
> >
> > On Wed, Jul 7, 2010 at 12:16 AM, Jonathan Ellis <jb...@gmail.com> wrote:
> >>
> >> insert is insert-or-update.  leaving out a column from an update
> >> doesn't delete it, you need to use the remove method for that.
> >>
> >> On Tue, Jul 6, 2010 at 7:41 AM, Moses Dinakaran
> >> <mo...@gmail.com> wrote:
> >> > Hi All,
> >> >
> >> > I have a query related to deleting a column inside a super column
> >> >
> >> > The following is my cassandra schema
> >> >
> >> > [cache_pages_key_hash] => Array
> >> >        (
> >> >            [hash_1] => Array
> >> >                (
> >> >                    [1] => 4c330e95195f9
> >> >                    [2] => 4c330e951f18b
> >> >                    [3] => 4c330e9521f3d
> >> >                )
> >> >
> >> >        )
> >> >
> >> >
> >> > No I wanted to remove the index [1] => 4c330e95195f9 from the
> >> > supercolumn [hash_1]
> >> >
> >> > Through phpCassa I am doing the following
> >> >
> >> > $updatedRecord   =  array("hash_1" => Array
> >> >                                (
> >> >                                    2 => "4c330e951f18b"
> >> >                                    3 => "4c330e9521f3d"
> >> >                               )
> >> >                             )
> >> >
> >> >
> >> > $cassandraInstance->insert('cache_pages_key_hash',$updateRecord );
> >> >
> >> > But while I fetch the record again
> >> >
> >> > I was getting the original records ie the column 1 is not removed from
> >> >
> >> >
> >> > [cache_pages_key_hash] => Array
> >> >        (
> >> >            [hash_1] => Array
> >> >                (
> >> >                    [1] => 4c330e95195f9
> >> >                    [2] => 4c330e951f18b
> >> >                    [3] => 4c330e9521f3d
> >> >                )
> >> >
> >> >        )
> >> >
> >> >
> >> > But at the same time If I am updating the index 1
> >> >
> >> > ie
> >> > $updateRecord   =  array("hash_1" => Array
> >> >                                (
> >> >                                   1  => ' able to update'
> >> >                                    2 => "4c330e951f18b"
> >> >                                    3 => "4c330e9521f3d"
> >> >                               )
> >> >                             )
> >> >
> >> > $cassandraInstance->insert('cache_pages_key_hash',$updateRecord );
> >> >
> >> > The records is being updated, Only problem is that  deleting dosent
> >> > happens.
> >> >
> >> > My question is that is this behavior is expected as explained in the
> >> > article
> >> > Distributed deletes in the Cassandra database
> >> > http://spyced.blogspot.com/2010/02/distributed-deletes-in-cassandra.html
> >> >
> >> > or I am doing wrong.
> >> >
> >> >
> >> > Thanks,
> >> > Moses.
> >> >
> >>
> >>
> >>
> >> --
> >> Jonathan Ellis
> >> Project Chair, Apache Cassandra
> >> co-founder of Riptano, the source for professional Cassandra support
> >> http://riptano.com
> >
> >
>
>
>
> --
> Jonathan Ellis
> Project Chair, Apache Cassandra
> co-founder of Riptano, the source for professional Cassandra support
> http://riptano.com

Re: Query on delete a column inside a super column

Posted by Jonathan Ellis <jb...@gmail.com>.
the thrift api allows you to optionally specify column and subcolumn
as well.  no idea how or if phpCassa exposes this though.

On Wed, Jul 7, 2010 at 1:51 AM, Moses Dinakaran
<mo...@gmail.com> wrote:
> Hi,
>
> Thanks for the reply,
>
> The remove method
> $cassandraInstance->remove('cache_pages_key_hash', 'hash_1' )
>
> which will remove the whole key, But I don't want to do that, I need to
> remove one column inside that key
>
> Can you please tell me how to use the remove method in this case.
>
>
> Regards,
> Moses.
>
>
> On Wed, Jul 7, 2010 at 12:16 AM, Jonathan Ellis <jb...@gmail.com> wrote:
>>
>> insert is insert-or-update.  leaving out a column from an update
>> doesn't delete it, you need to use the remove method for that.
>>
>> On Tue, Jul 6, 2010 at 7:41 AM, Moses Dinakaran
>> <mo...@gmail.com> wrote:
>> > Hi All,
>> >
>> > I have a query related to deleting a column inside a super column
>> >
>> > The following is my cassandra schema
>> >
>> > [cache_pages_key_hash] => Array
>> >        (
>> >            [hash_1] => Array
>> >                (
>> >                    [1] => 4c330e95195f9
>> >                    [2] => 4c330e951f18b
>> >                    [3] => 4c330e9521f3d
>> >                )
>> >
>> >        )
>> >
>> >
>> > No I wanted to remove the index [1] => 4c330e95195f9 from the
>> > supercolumn [hash_1]
>> >
>> > Through phpCassa I am doing the following
>> >
>> > $updatedRecord   =  array("hash_1" => Array
>> >                                (
>> >                                    2 => "4c330e951f18b"
>> >                                    3 => "4c330e9521f3d"
>> >                               )
>> >                             )
>> >
>> >
>> > $cassandraInstance->insert('cache_pages_key_hash',$updateRecord );
>> >
>> > But while I fetch the record again
>> >
>> > I was getting the original records ie the column 1 is not removed from
>> >
>> >
>> > [cache_pages_key_hash] => Array
>> >        (
>> >            [hash_1] => Array
>> >                (
>> >                    [1] => 4c330e95195f9
>> >                    [2] => 4c330e951f18b
>> >                    [3] => 4c330e9521f3d
>> >                )
>> >
>> >        )
>> >
>> >
>> > But at the same time If I am updating the index 1
>> >
>> > ie
>> > $updateRecord   =  array("hash_1" => Array
>> >                                (
>> >                                   1  => ' able to update'
>> >                                    2 => "4c330e951f18b"
>> >                                    3 => "4c330e9521f3d"
>> >                               )
>> >                             )
>> >
>> > $cassandraInstance->insert('cache_pages_key_hash',$updateRecord );
>> >
>> > The records is being updated, Only problem is that  deleting dosent
>> > happens.
>> >
>> > My question is that is this behavior is expected as explained in the
>> > article
>> > Distributed deletes in the Cassandra database
>> > http://spyced.blogspot.com/2010/02/distributed-deletes-in-cassandra.html
>> >
>> > or I am doing wrong.
>> >
>> >
>> > Thanks,
>> > Moses.
>> >
>>
>>
>>
>> --
>> Jonathan Ellis
>> Project Chair, Apache Cassandra
>> co-founder of Riptano, the source for professional Cassandra support
>> http://riptano.com
>
>



-- 
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of Riptano, the source for professional Cassandra support
http://riptano.com

Re: Query on delete a column inside a super column

Posted by Moses Dinakaran <mo...@gmail.com>.
Hi,

Thanks for the reply,

The remove method
$cassandraInstance->remove('cache_pages_key_hash', 'hash_1' )

which will remove the whole key, But I don't want to do that, I need to
remove one column inside that key

Can you please tell me how to use the remove method in this case.


Regards,
Moses.


On Wed, Jul 7, 2010 at 12:16 AM, Jonathan Ellis <jb...@gmail.com> wrote:

> insert is insert-or-update.  leaving out a column from an update
> doesn't delete it, you need to use the remove method for that.
>
> On Tue, Jul 6, 2010 at 7:41 AM, Moses Dinakaran
> <mo...@gmail.com> wrote:
> > Hi All,
> >
> > I have a query related to deleting a column inside a super column
> >
> > The following is my cassandra schema
> >
> > [cache_pages_key_hash] => Array
> >        (
> >            [hash_1] => Array
> >                (
> >                    [1] => 4c330e95195f9
> >                    [2] => 4c330e951f18b
> >                    [3] => 4c330e9521f3d
> >                )
> >
> >        )
> >
> >
> > No I wanted to remove the index [1] => 4c330e95195f9 from the
> > supercolumn [hash_1]
> >
> > Through phpCassa I am doing the following
> >
> > $updatedRecord   =  array("hash_1" => Array
> >                                (
> >                                    2 => "4c330e951f18b"
> >                                    3 => "4c330e9521f3d"
> >                               )
> >                             )
> >
> >
> > $cassandraInstance->insert('cache_pages_key_hash',$updateRecord );
> >
> > But while I fetch the record again
> >
> > I was getting the original records ie the column 1 is not removed from
> >
> >
> > [cache_pages_key_hash] => Array
> >        (
> >            [hash_1] => Array
> >                (
> >                    [1] => 4c330e95195f9
> >                    [2] => 4c330e951f18b
> >                    [3] => 4c330e9521f3d
> >                )
> >
> >        )
> >
> >
> > But at the same time If I am updating the index 1
> >
> > ie
> > $updateRecord   =  array("hash_1" => Array
> >                                (
> >                                   1  => ' able to update'
> >                                    2 => "4c330e951f18b"
> >                                    3 => "4c330e9521f3d"
> >                               )
> >                             )
> >
> > $cassandraInstance->insert('cache_pages_key_hash',$updateRecord );
> >
> > The records is being updated, Only problem is that  deleting dosent
> happens.
> >
> > My question is that is this behavior is expected as explained in the
> article
> > Distributed deletes in the Cassandra database
> > http://spyced.blogspot.com/2010/02/distributed-deletes-in-cassandra.html
> >
> > or I am doing wrong.
> >
> >
> > Thanks,
> > Moses.
> >
>
>
>
> --
> Jonathan Ellis
> Project Chair, Apache Cassandra
> co-founder of Riptano, the source for professional Cassandra support
> http://riptano.com
>

Re: Query on delete a column inside a super column

Posted by Jonathan Ellis <jb...@gmail.com>.
insert is insert-or-update.  leaving out a column from an update
doesn't delete it, you need to use the remove method for that.

On Tue, Jul 6, 2010 at 7:41 AM, Moses Dinakaran
<mo...@gmail.com> wrote:
> Hi All,
>
> I have a query related to deleting a column inside a super column
>
> The following is my cassandra schema
>
> [cache_pages_key_hash] => Array
>        (
>            [hash_1] => Array
>                (
>                    [1] => 4c330e95195f9
>                    [2] => 4c330e951f18b
>                    [3] => 4c330e9521f3d
>                )
>
>        )
>
>
> No I wanted to remove the index [1] => 4c330e95195f9 from the
> supercolumn [hash_1]
>
> Through phpCassa I am doing the following
>
> $updatedRecord   =  array("hash_1" => Array
>                                (
>                                    2 => "4c330e951f18b"
>                                    3 => "4c330e9521f3d"
>                               )
>                             )
>
>
> $cassandraInstance->insert('cache_pages_key_hash',$updateRecord );
>
> But while I fetch the record again
>
> I was getting the original records ie the column 1 is not removed from
>
>
> [cache_pages_key_hash] => Array
>        (
>            [hash_1] => Array
>                (
>                    [1] => 4c330e95195f9
>                    [2] => 4c330e951f18b
>                    [3] => 4c330e9521f3d
>                )
>
>        )
>
>
> But at the same time If I am updating the index 1
>
> ie
> $updateRecord   =  array("hash_1" => Array
>                                (
>                                   1  => ' able to update'
>                                    2 => "4c330e951f18b"
>                                    3 => "4c330e9521f3d"
>                               )
>                             )
>
> $cassandraInstance->insert('cache_pages_key_hash',$updateRecord );
>
> The records is being updated, Only problem is that  deleting dosent happens.
>
> My question is that is this behavior is expected as explained in the article
> Distributed deletes in the Cassandra database
> http://spyced.blogspot.com/2010/02/distributed-deletes-in-cassandra.html
>
> or I am doing wrong.
>
>
> Thanks,
> Moses.
>



-- 
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of Riptano, the source for professional Cassandra support
http://riptano.com