Reputation: 3579
I am trying to create a following hierarchy: UserId as rowKey, Hourly time series as columns and inside each hourly column I want to have a user specific information such as hourly activity.
{
UserId:long
{
Timestamp:datetime{
pageview: integer,
clicks:integer
}
}
I've read that it is possible to achieve it using supercolumns
but at the same time it was mentioned that supercolumns
are outdated right now. If it is true, any alternatives I can use?
Could you please provide me CQL / Java thrift example how should I create and insert such type of structure in Cassandra?
Thanks!
Upvotes: 0
Views: 208
Reputation: 991
If your information is subjected to a particular used and accessed together . For example,if you are at anytime , require both clicks and pageview, i would suggest you to use it as a json store
CREATE TABLE user_click_by_hour(
userid long,
time_stamp timestamp,
val text,
PRIMARY KEY(userid,time_stamp)
)
val is a json object containing clicks, pageview and etc.
Advantage
1.You need not worry about altering the table for adding extra column, which add a null value for each and every previous entry
Upvotes: 0
Reputation: 716
You can user composite primary key for this, I add a table creation CQL query for the table. And you can use counter column for clicks.
CREATE TABLE user_click_by_hour(
userid long,
time_stamp timestamp,
clicks int,
pageview int,
PRIMARY KEY(userid,time_stamp)
)
Upvotes: 1