You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Morgan Segalis <ms...@gmail.com> on 2012/08/30 13:22:04 UTC

Store a timeline with uniques properties

Hi everyone,

I'm trying to use cassandra in order to store a "timeline", but with values that must be unique (replaced). (So not really a timeline, but didn't find a better word for it)

Let's me give you an example :

- An user have a list of friends
- Friends can change their nickname, status, profile picture, etc...

at the beginning the CF will look like that for user1: 

lte = latest-timestamp-entry, which is the timestamp of the entry (-1 -2 -3 means that the timestamp are older)

user1 row :			|		lte			|		lte -1		|		lte -2		| 		lte -3		|		lte -4		|
		values :		| user2-name-change | user3-pic-change	| user4-status-change | user2-pic-change	| user2-status-change |

If for example, user2 changes it's picture, the row should look like that : 

user1 row :			|		lte			|		lte -1		|		lte -2		| 		lte -3		|		lte -4		 |
		values :		|   user2-pic-change	| user2-name-change | user3-pic-change	| user4-status-change | user2-status-change |

notice that user2-pic-change in the first representation (lte -3) has "moved" to the (lte) on the second representation.

That way when user1 connects again, It can retrieve only informations that occurred between the last time he connected.

e.g. : if the user1's last connexion date it between "lte -2" and "lte -3", then he will only be notified that :

- user2 has changed his picture
- user2 has changed his name
- user3 has changed his picture

I would not keep the old data since the "timeline" is saved locally on the client, and not on the server.
I really would like not to search for each column in order to find the "user2-pic-change", that can be long especially if the user has many friends.

Is there a simple way to do that with cassandra, or I am bound to create another CF, with column title holding the action e.g. "user2-pic-change" and for value the timestamp when it appears ?

Thanks,

Morgan.


Re: Store a timeline with uniques properties

Posted by Morgan Segalis <ms...@gmail.com>.
Nevermind, it is called composite columns. 

Thank you for your help. 

Morgan. 

Le 31 août 2012 à 06:05, aaron morton <aa...@thelastpickle.com> a écrit :

> Consider trying…
> 
> UserTimeline CF
> 
> row_key: <user_id>
> column_names: <timestamp, other_user_id, action>
> column_values: action details
> 
> To get the changes between two times specify the start and end timestamps and do not include the other components of the column name. 
> 
> e.g. from <1234, NULL, NULL> to <6789, NULL, NULL>
> 
> Cheers
> 
> -----------------
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
> 
> On 30/08/2012, at 11:32 PM, Morgan Segalis <ms...@gmail.com> wrote:
> 
>> Sorry for the scheme that has not keep the right tabulation for some people...
>> Here's a space-version instead of a tabulation.
>> 
>> user1 row :            |               lte                    |              lte -1                |               lte -2                |              lte -3               |               lte -4               |
>>          values :        | user2-name-change | user3-pic-change       | user4-status-change | user2-pic-change     | user2-status-change |
>> 
>> If for example, user2 changes it's picture, the row should look like that : 
>> 
>> user1 row :                    |                lte                   |               lte -1               |               lte -2               |                lte -3              |              lte -4                |
>>                values :          |   user2-pic-change    | user2-name-change | user3-pic-change       | user4-status-change | user2-status-change |
>> 
>> Le 30 août 2012 à 13:22, Morgan Segalis a écrit :
>> 
>>> Hi everyone,
>>> 
>>> I'm trying to use cassandra in order to store a "timeline", but with values that must be unique (replaced). (So not really a timeline, but didn't find a better word for it)
>>> 
>>> Let's me give you an example :
>>> 
>>> - An user have a list of friends
>>> - Friends can change their nickname, status, profile picture, etc...
>>> 
>>> at the beginning the CF will look like that for user1: 
>>> 
>>> lte = latest-timestamp-entry, which is the timestamp of the entry (-1 -2 -3 means that the timestamp are older)
>>> 
>>> user1 row :			|		lte			|		lte -1		|		lte -2		| 		lte -3		|		lte -4		|
>>> 		values :		| user2-name-change | user3-pic-change	| user4-status-change | user2-pic-change	| user2-status-change |
>>> 
>>> If for example, user2 changes it's picture, the row should look like that : 
>>> 
>>> user1 row :			|		lte			|		lte -1		|		lte -2		| 		lte -3		|		lte -4		 |
>>> 		values :		|   user2-pic-change	| user2-name-change | user3-pic-change	| user4-status-change | user2-status-change |
>>> 
>>> notice that user2-pic-change in the first representation (lte -3) has "moved" to the (lte) on the second representation.
>>> 
>>> That way when user1 connects again, It can retrieve only informations that occurred between the last time he connected.
>>> 
>>> e.g. : if the user1's last connexion date it between "lte -2" and "lte -3", then he will only be notified that :
>>> 
>>> - user2 has changed his picture
>>> - user2 has changed his name
>>> - user3 has changed his picture
>>> 
>>> I would not keep the old data since the "timeline" is saved locally on the client, and not on the server.
>>> I really would like not to search for each column in order to find the "user2-pic-change", that can be long especially if the user has many friends.
>>> 
>>> Is there a simple way to do that with cassandra, or I am bound to create another CF, with column title holding the action e.g. "user2-pic-change" and for value the timestamp when it appears ?
>>> 
>>> Thanks,
>>> 
>>> Morgan.
> 

Re: Store a timeline with uniques properties

Posted by Morgan Segalis <ms...@gmail.com>.
Hi Aaron,

That's great news... Would you know the name of this feature so I can look further into it ?

Thanks,

Morgan. 

Le 31 août 2012 à 06:05, aaron morton <aa...@thelastpickle.com> a écrit :

> Consider trying…
> 
> UserTimeline CF
> 
> row_key: <user_id>
> column_names: <timestamp, other_user_id, action>
> column_values: action details
> 
> To get the changes between two times specify the start and end timestamps and do not include the other components of the column name. 
> 
> e.g. from <1234, NULL, NULL> to <6789, NULL, NULL>
> 
> Cheers
> 
> -----------------
> Aaron Morton
> Freelance Developer
> @aaronmorton
> http://www.thelastpickle.com
> 
> On 30/08/2012, at 11:32 PM, Morgan Segalis <ms...@gmail.com> wrote:
> 
>> Sorry for the scheme that has not keep the right tabulation for some people...
>> Here's a space-version instead of a tabulation.
>> 
>> user1 row :            |               lte                    |              lte -1                |               lte -2                |              lte -3               |               lte -4               |
>>          values :        | user2-name-change | user3-pic-change       | user4-status-change | user2-pic-change     | user2-status-change |
>> 
>> If for example, user2 changes it's picture, the row should look like that : 
>> 
>> user1 row :                    |                lte                   |               lte -1               |               lte -2               |                lte -3              |              lte -4                |
>>                values :          |   user2-pic-change    | user2-name-change | user3-pic-change       | user4-status-change | user2-status-change |
>> 
>> Le 30 août 2012 à 13:22, Morgan Segalis a écrit :
>> 
>>> Hi everyone,
>>> 
>>> I'm trying to use cassandra in order to store a "timeline", but with values that must be unique (replaced). (So not really a timeline, but didn't find a better word for it)
>>> 
>>> Let's me give you an example :
>>> 
>>> - An user have a list of friends
>>> - Friends can change their nickname, status, profile picture, etc...
>>> 
>>> at the beginning the CF will look like that for user1: 
>>> 
>>> lte = latest-timestamp-entry, which is the timestamp of the entry (-1 -2 -3 means that the timestamp are older)
>>> 
>>> user1 row :			|		lte			|		lte -1		|		lte -2		| 		lte -3		|		lte -4		|
>>> 		values :		| user2-name-change | user3-pic-change	| user4-status-change | user2-pic-change	| user2-status-change |
>>> 
>>> If for example, user2 changes it's picture, the row should look like that : 
>>> 
>>> user1 row :			|		lte			|		lte -1		|		lte -2		| 		lte -3		|		lte -4		 |
>>> 		values :		|   user2-pic-change	| user2-name-change | user3-pic-change	| user4-status-change | user2-status-change |
>>> 
>>> notice that user2-pic-change in the first representation (lte -3) has "moved" to the (lte) on the second representation.
>>> 
>>> That way when user1 connects again, It can retrieve only informations that occurred between the last time he connected.
>>> 
>>> e.g. : if the user1's last connexion date it between "lte -2" and "lte -3", then he will only be notified that :
>>> 
>>> - user2 has changed his picture
>>> - user2 has changed his name
>>> - user3 has changed his picture
>>> 
>>> I would not keep the old data since the "timeline" is saved locally on the client, and not on the server.
>>> I really would like not to search for each column in order to find the "user2-pic-change", that can be long especially if the user has many friends.
>>> 
>>> Is there a simple way to do that with cassandra, or I am bound to create another CF, with column title holding the action e.g. "user2-pic-change" and for value the timestamp when it appears ?
>>> 
>>> Thanks,
>>> 
>>> Morgan.
> 

Re: Store a timeline with uniques properties

Posted by aaron morton <aa...@thelastpickle.com>.
Consider trying…

UserTimeline CF

row_key: <user_id>
column_names: <timestamp, other_user_id, action>
column_values: action details

To get the changes between two times specify the start and end timestamps and do not include the other components of the column name. 

e.g. from <1234, NULL, NULL> to <6789, NULL, NULL>

Cheers

-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 30/08/2012, at 11:32 PM, Morgan Segalis <ms...@gmail.com> wrote:

> Sorry for the scheme that has not keep the right tabulation for some people...
> Here's a space-version instead of a tabulation.
> 
> user1 row :            |               lte                    |              lte -1                |               lte -2                |              lte -3               |               lte -4               |
>          values :        | user2-name-change | user3-pic-change       | user4-status-change | user2-pic-change     | user2-status-change |
> 
> If for example, user2 changes it's picture, the row should look like that : 
> 
> user1 row :                    |                lte                   |               lte -1               |               lte -2               |                lte -3              |              lte -4                |
>                values :          |   user2-pic-change    | user2-name-change | user3-pic-change       | user4-status-change | user2-status-change |
> 
> Le 30 août 2012 à 13:22, Morgan Segalis a écrit :
> 
>> Hi everyone,
>> 
>> I'm trying to use cassandra in order to store a "timeline", but with values that must be unique (replaced). (So not really a timeline, but didn't find a better word for it)
>> 
>> Let's me give you an example :
>> 
>> - An user have a list of friends
>> - Friends can change their nickname, status, profile picture, etc...
>> 
>> at the beginning the CF will look like that for user1: 
>> 
>> lte = latest-timestamp-entry, which is the timestamp of the entry (-1 -2 -3 means that the timestamp are older)
>> 
>> user1 row :			|		lte			|		lte -1		|		lte -2		| 		lte -3		|		lte -4		|
>> 		values :		| user2-name-change | user3-pic-change	| user4-status-change | user2-pic-change	| user2-status-change |
>> 
>> If for example, user2 changes it's picture, the row should look like that : 
>> 
>> user1 row :			|		lte			|		lte -1		|		lte -2		| 		lte -3		|		lte -4		 |
>> 		values :		|   user2-pic-change	| user2-name-change | user3-pic-change	| user4-status-change | user2-status-change |
>> 
>> notice that user2-pic-change in the first representation (lte -3) has "moved" to the (lte) on the second representation.
>> 
>> That way when user1 connects again, It can retrieve only informations that occurred between the last time he connected.
>> 
>> e.g. : if the user1's last connexion date it between "lte -2" and "lte -3", then he will only be notified that :
>> 
>> - user2 has changed his picture
>> - user2 has changed his name
>> - user3 has changed his picture
>> 
>> I would not keep the old data since the "timeline" is saved locally on the client, and not on the server.
>> I really would like not to search for each column in order to find the "user2-pic-change", that can be long especially if the user has many friends.
>> 
>> Is there a simple way to do that with cassandra, or I am bound to create another CF, with column title holding the action e.g. "user2-pic-change" and for value the timestamp when it appears ?
>> 
>> Thanks,
>> 
>> Morgan.
>> 
> 


Re: Store a timeline with uniques properties

Posted by Morgan Segalis <ms...@gmail.com>.
Sorry for the scheme that has not keep the right tabulation for some people...
Here's a space-version instead of a tabulation.

user1 row :            |               lte                    |              lte -1                |               lte -2                |              lte -3               |               lte -4               |
          values :        | user2-name-change | user3-pic-change       | user4-status-change | user2-pic-change     | user2-status-change |

If for example, user2 changes it's picture, the row should look like that : 

user1 row :                    |                lte                   |               lte -1               |               lte -2               |                lte -3              |              lte -4                |
                values :          |   user2-pic-change    | user2-name-change | user3-pic-change       | user4-status-change | user2-status-change |

Le 30 août 2012 à 13:22, Morgan Segalis a écrit :

> Hi everyone,
> 
> I'm trying to use cassandra in order to store a "timeline", but with values that must be unique (replaced). (So not really a timeline, but didn't find a better word for it)
> 
> Let's me give you an example :
> 
> - An user have a list of friends
> - Friends can change their nickname, status, profile picture, etc...
> 
> at the beginning the CF will look like that for user1: 
> 
> lte = latest-timestamp-entry, which is the timestamp of the entry (-1 -2 -3 means that the timestamp are older)
> 
> user1 row :			|		lte			|		lte -1		|		lte -2		| 		lte -3		|		lte -4		|
> 		values :		| user2-name-change | user3-pic-change	| user4-status-change | user2-pic-change	| user2-status-change |
> 
> If for example, user2 changes it's picture, the row should look like that : 
> 
> user1 row :			|		lte			|		lte -1		|		lte -2		| 		lte -3		|		lte -4		 |
> 		values :		|   user2-pic-change	| user2-name-change | user3-pic-change	| user4-status-change | user2-status-change |
> 
> notice that user2-pic-change in the first representation (lte -3) has "moved" to the (lte) on the second representation.
> 
> That way when user1 connects again, It can retrieve only informations that occurred between the last time he connected.
> 
> e.g. : if the user1's last connexion date it between "lte -2" and "lte -3", then he will only be notified that :
> 
> - user2 has changed his picture
> - user2 has changed his name
> - user3 has changed his picture
> 
> I would not keep the old data since the "timeline" is saved locally on the client, and not on the server.
> I really would like not to search for each column in order to find the "user2-pic-change", that can be long especially if the user has many friends.
> 
> Is there a simple way to do that with cassandra, or I am bound to create another CF, with column title holding the action e.g. "user2-pic-change" and for value the timestamp when it appears ?
> 
> Thanks,
> 
> Morgan.
>