Skip to content

Commit

Permalink
new tweet layout, counters
Browse files Browse the repository at this point in the history
  • Loading branch information
amorton committed Jul 30, 2012
1 parent 8da7645 commit 304bc7d
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 206 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ pip-log.txt
#Mr Developer
.mr.developer.cfg

.dev-env
.dev-env
.DS_Store
84 changes: 61 additions & 23 deletions cassandra-schema.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,53 @@ AND
;

/*
Store all tweets by a user on one row.
One row per user.
row key is user_name.
column name is (tweet_id, property_name) e.g. (1234, "timestamp").
column values are text
column names are counter names, e.g. "tweets", "followers".
column values counters
*/
CREATE COLUMN FAMILY
UserTweets
UserMetrics
WITH
key_validation_class = UTF8Type
AND
comparator = 'CompositeType(IntegerType(reversed=true), UTF8Type)'
comparator = UTF8Type
AND
default_validation_class = CounterColumnType
;

/*
One row per tweet.
row key is tweet_id.
column name is property_name.
column values are text
*/
CREATE COLUMN FAMILY
Tweet
WITH
key_validation_class = IntegerType
AND
comparator = UTF8Type
AND
default_validation_class = UTF8Type
;

/*
Store all tweets a user has sent or received in one row.
One row for all tweets from a user. Stores a reference to the Tweet CF.
row key is user_name.
column name is tweet_id
column values is not used.
*/
CREATE COLUMN FAMILY
UserTweets
WITH
key_validation_class = UTF8Type
AND
comparator = 'IntegerType(reversed=true)'
;

/*
One row for all tweets a user has sent or received.
row key is user_name
column name is tweet_id.
column value is JSON packed tweet
Expand All @@ -51,9 +81,9 @@ AND
;

/*
Store recent tweets per day.
row key is todays date.
column name is (tweet_id, user_name)
One row for all tweets sent in a day. Stores reference to Tweet CF.
row key is todays date, e.g. "2011-08-04"
column name is (tweet_id, user_name) (user_name included for info purposes)
column value not used
*/
CREATE COLUMN FAMILY
Expand All @@ -64,31 +94,39 @@ AND
comparator = 'CompositeType(IntegerType(reversed=true), UTF8Type)'
;

/*
One row for all users who have a relationship with a user.
Relationships are directional: "followers", "following"
Column name is user_name.
*/
CREATE COLUMN FAMILY
OrderedFollowers
Relationships
WITH
key_validation_class = UTF8Type
key_validation_class = 'CompositeType(UTF8Type, UTF8Type)'
AND
comparator = 'CompositeType(IntegerType(reversed=true), UTF8Type)'
comparator = UTF8Type
;

/*
One row for all users who have a relationship with a user.
Relationships are directional: "followers", "following"
Row key is (user_name, relation_type)
Column name is (timestamp, user_name) to order relationships by creation
Column value is not used.
*/
CREATE COLUMN FAMILY
OrderedFollowing
OrderedRelationships
WITH
key_validation_class = UTF8Type
key_validation_class = 'CompositeType(UTF8Type, UTF8Type)'
AND
comparator = 'CompositeType(IntegerType(reversed=true), UTF8Type)'
;

CREATE COLUMN FAMILY
AllFollowers
WITH
key_validation_class = UTF8Type
AND
comparator = UTF8Type
;


/*
One row for each tweet and the users it was delivered to.
Row key is tweet_id
Column name is user_name
*/
CREATE COLUMN FAMILY
TweetDelivery
WITH
Expand Down
Loading

0 comments on commit 304bc7d

Please sign in to comment.