apache cassandra at narmal 2014
Post on 05-Dec-2014
227 Views
Preview:
DESCRIPTION
TRANSCRIPT
Narmal C*
● iOS / Scala / C* / AWS
Another Email App
● Email “broken” / “sucks”
Concept
ConceptConversation
Topic Topic
Email Email Email Email
CREATE TABLE conversations ( user_id uuid, ts big_int, recipients_hash text, PRIMARY KEY(user_id, ts);
Data Model - Conversations
Data Model - Conversations
1
INSERT INTO.conversations (user_id, ts, rec_hash) VALUES (1, ‘141...x‘, pr135t’);
INSERT INTO.conversations (user_id, ts, subject) VALUES (1, ‘141...y‘, ‘ra881’);
INSERT INTO.conversations (user_id, ts, subject) VALUES (1, ‘141...z‘, ‘pr135t!’);
141y:rec_hash
ra881
141x:rec_hash
pr135t
141z:rec_hash
pr135t
def mostRecent[T](models: List[T])(implicit tc: MostRecentItems[T]): Seq[T] = { models.groupBy(model => tc.member(model)) .map(_._2.headOption) .filter(_.isDefined) .map(_.get).toSeq .sortBy(model => tc.ts(model)).reverse}
Data Model - Edge Case
2x recipients_hash => ‘pr135t
141y:rec_hash
ra881
141x:rec_hash
pr135t
141z:rec_hash
pr135t
Data Model - TopicsCREATE TABLE topics ( user_id uuid, rec_hash text, ts bigint, thread_id, PRIMARY KEY((user_id, rec_hash), ts);
1 | pr135t
INSERT INTO topics (user_id, rec_hash, ts, thread_id) VALUES (1, ‘pr135t’, ‘141...x‘, ‘d97’);
INSERT INTO topics (user_id, rec_hash, ts, thread_id) VALUES (1, ‘ra881’, ‘141...y‘, c24);INSERT INTO topics (user_id, rec_hash, ts, thread_id) VALUES (1, ‘pr135t!’, ‘141...z‘, ‘d97’);
141y:thread_id
c24
141x:thread_id
d97
141z:thread_id
d97
1 | ra881
Data Model - Emails
CREATE TABLE emails_by_topic ( user_id uuid, thread_id text, ts big_int, id text, body text, PRIMARY KEY(user_id, thread_id), ts, id);
1 | d97
INSERT INTO emails (user_id, thread_id, ts, id, body) VALUES (1, ‘d97’, ‘141...x‘, ‘32’, “GO”);
INSERT INTO emails (user_id, thread_id, ts, id, body) VALUES (1, ‘c24’, ‘141...y‘, 99, “YEAH”);INSERT INTO topics (user_id, thread_id, ts, id, body) VALUES (1, ‘d97’, ‘141...z‘, 33, ‘ROYALS’);
141y:99:body
YEAH
141x:32:body
GO
141z:33:body
ROYALS
1 | c24
Concept 2
Concept 2Conversation
Email Email Email Email
Data Model - Emails 2
CREATE TABLE emails_by_conversation ( user_id uuid, rec_hash text, ts big_int, id text, body text, PRIMARY KEY(user_id, rec_hash), ts, id);
thread_id
1 | pr135t
INSERT INTO emails (user_id, rec_hash, ts, id, body) VALUES (1, ‘pr135t’, ‘141...x‘, ‘32’, “YEAH!”);
INSERT INTO emails (user_id, rec_hash, ts, id, body) VALUES (1, ‘ra881’, ‘141...y‘, 99, “GO”);INSERT INTO topics (user_id, rec_hash, ts, id, body) VALUES (1, ‘pr135t’, ‘141...z‘, 33, ‘ROYALS’);
141y:99:body
GO
141x:32:body
YEAH
141z:33:body
ROYALS
1 | ra881
Other● EC2
● Multiple data centers
● Spark
top related