C*SC301 - Paxos, Tuples and UDTs

22
Tuples, LWTs and UDTs S 301 Paxos, Tuples and User Defined Types

Transcript of C*SC301 - Paxos, Tuples and UDTs

Page 1: C*SC301 - Paxos, Tuples and UDTs

Tuples, LWTs and UDTs

S 301Paxos, Tuples and User Defined Types

Page 2: C*SC301 - Paxos, Tuples and UDTs

Shameless Plug

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Page 3: C*SC301 - Paxos, Tuples and UDTs

From humble beginnings

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Page 4: C*SC301 - Paxos, Tuples and UDTs

CAP Theorem Refresher

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Page 5: C*SC301 - Paxos, Tuples and UDTs

Planning your Data Model

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Start with Queries

Denormalize to Optimize

Planning for Concurrent Writes

Who is jbellis a subscriber of?

Blog entry will have a body, user and category.

Page 6: C*SC301 - Paxos, Tuples and UDTs

From humble beginnings

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Page 7: C*SC301 - Paxos, Tuples and UDTs

What about transactions?

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Page 8: C*SC301 - Paxos, Tuples and UDTs

What about transactions?

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Page 9: C*SC301 - Paxos, Tuples and UDTs

Why not transactions?

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Page 10: C*SC301 - Paxos, Tuples and UDTs

Enter PaxosLight Weight Transactions

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Prepares a proposal that is sent to a number of Acceptors.Waits on a an acknowledgement (in form of promise) from Acceptors.Sends accept message to Quorum of Acceptors with new value to commit.Returns success? completion to client.

Determines if proposal is newer than what it has seen.Acknowledges/agree with its own highest proposal value seen AND the current value (of what is to be set).Receive message to commit new value.Accept and return on successful commit of value.

Page 11: C*SC301 - Paxos, Tuples and UDTs

Paxos… (in Cassandra)

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Page 12: C*SC301 - Paxos, Tuples and UDTs

Practical LWTs in C*

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Page 13: C*SC301 - Paxos, Tuples and UDTs

Space-time

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Page 14: C*SC301 - Paxos, Tuples and UDTs

Enter TuplesCartesian co-ordinates

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Page 15: C*SC301 - Paxos, Tuples and UDTs

Tracking the drone in real-time

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Page 16: C*SC301 - Paxos, Tuples and UDTs

Embedding metadataComplex Data Types & JSON

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

{ "mls_number": "C1818310", "address": { "street_number": 44, "street_name": "kennedy road", "unit": "" }, "listing_price": 459999, "description": "Victorian house set on the gorgeous park...", "date_listed": "2013-06-21", "rooms": { { "room": "kitchen", "dimensions": { "width": "14.2", "length": "16.8", "units": "feet" } }, { "room": "bedroom", "dimensions": { "width": "13.2", "length": "19.6", "units": "feet" } } }}

CREATE TABLE listings ( mls_number text, address text, listing_price double, description text, date_listed timestamp, PRIMARY KEY (mls_number));

CREATE TABLE room_data ( mls_number text, room_id uuid, room_name text, PRIMARY KEY (mls_number, room_id));

CREATE TABLE room_dimensions ( room_id uuid, width double, length double, units text, PRIMARY KEY (room_id));

Page 17: C*SC301 - Paxos, Tuples and UDTs

User Defined Types cont...

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

{ "mls_number": "C1818310", "address": { "street_number": 44, "street_name": "kennedy road", "unit": "" }, "listing_price": 459999, "description": "Victorian house set on the gorgeous park...", "date_listed": "2013-06-21", "rooms": { { "room": "kitchen", "dimensions": { "width": "14.2", "length": "16.8", "units": "feet" } }, { "room": "bedroom", "dimensions": { "width": "13.2", "length": "19.6", "units": "feet" } } }}

{ "mls_number": "C1818310", "address": { "street_number": 44, "street_name": "kennedy road", "unit": "" }, "listing_price": 459999, "description": "Victorian house set on the gorgeous park...", "date_listed": "2013-06-21", "rooms": { { "room": "kitchen", "dimensions": { "width": "14.2", "length": "16.8", "units": "feet" } }, { "room": "bedroom", "dimensions": { "width": "13.2", "length": "19.6", "units": "feet" } } }}

CREATE TYPE room_dimensions ( width double, length double, units text);

{ "mls_number": "C1818310", "address": { "street_number": 44, "street_name": "kennedy road", "unit": "" }, "listing_price": 459999, "description": "Victorian house set on the gorgeous park...", "date_listed": "2013-06-21", "rooms": { { "room": "kitchen", "dimensions": { "width": "14.2", "length": "16.8", "units": "feet" } }, { "room": "bedroom", "dimensions": { "width": "13.2", "length": "19.6", "units": "feet" } } }}

CREATE TYPE mls_address ( street_number int, street_name text, unit text);

CREATE TABLE listings ( mls_number text, address frozen <mls_address>, listing_price double, description text, date_listed timestamp, rooms map <text, frozen <room_dimensions>>, PRIMARY KEY (mls_number));

{ "mls_number": "C1818310", "address": { "street_number": 44, "street_name": "kennedy road", "unit": "" }, "listing_price": 459999, "description": "Victorian house set on the gorgeous park...", "date_listed": "2013-06-21", "rooms": { { "room": "kitchen", "dimensions": { "width": "14.2", "length": "16.8", "units": "feet" } }, { "room": "bedroom", "dimensions": { "width": "13.2", "length": "19.6", "units": "feet" } } }}

Page 18: C*SC301 - Paxos, Tuples and UDTs

Pre 2.1.3 - there’s a catch

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Page 19: C*SC301 - Paxos, Tuples and UDTs

User Defined Types cont...

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

INSERT INTO listings (mls_number, listing_price, date_listed, description, address, rooms)VALUES (‘C1818310’,459999, ‘2013-06-21’, 'Victorian house set on the gorgeous park...', { street_number: 44, street_name: ‘Kennedy Road’, unit: ‘’ }, { ‘kitchen’: { width: 14.2, length: 16.8, unit: ‘feet’, }, ‘bedroom’: { width: 13.2, length: 19.6, unit: ‘feet’, } });

address frozen <mls_address>,

rooms map <text, frozen <room_dimensions>>

Page 20: C*SC301 - Paxos, Tuples and UDTs

Selecting UDTs

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

cqlsh:msl_test>SELECT kitchen.width, kitchen.length FROM listings WHERE mls_number = ‘C1818310’

kitchen.width | kitchen.length---------------------------------------------------------- 14.2 | 16.8

(1 rows)

cqlsh:msl_test>SELECT address FROM listings WHERE mls_number = ‘C1818310’

address--------------------------------------------------------------------------------{street_number: 44, street_name: ‘Kennedy Road’, unit: ‘’}

(1 rows)

Page 21: C*SC301 - Paxos, Tuples and UDTs

Did I mention…

We’re HIRING!

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc

Page 22: C*SC301 - Paxos, Tuples and UDTs

Did I mention…

We’re HIRING!

@VictorFAnjos

@Cassandra

@FicstarSoftware

@BrightlaneInc