Cassandra NoSQL, NoLimits!

20
Cassandra - NoSQL, NoLimits! Otávio Santana @otaviojava [email protected] [email protected]

Transcript of Cassandra NoSQL, NoLimits!

Cassandra - NoSQL, NoLimits!

Otávio Santana@[email protected]@apache.org

NoSQL

● Database● Doesn't use structure● Not Transaction● BASE● Five different types

SQL Key-value Document Column Graph

Table Bucket Collection Column Family

Vertex and Edge

Row Key/value pair

Document Column Vertex

Column Key/value pair

Key/value pair

Vertex and Edge property

Relationship Link Edge

Consistency LevelAvailability

Durability

● ANY● ONE● LOCAL_QUORON● EACH_QUORON● ALL

Gossip

Cassandra

● Commit log● Memtable● SSTable

write (k1, c1:v1)write (k2, c1:v1 C2:v2)write (k1, c1:v4 c3:v3 c2:v2)

k1 c1:v1 c2:v2 c3:v3k2 c1:v1 c2:v2

k1, c1:v1k2, c1:v1 C2:v2k1, c1:v4 c3:v3 c2:v2

k1 c1:v4 c2:v2 c3:v3k2 c1:v1 c2:v2

Cassandra● Gossip● Partitioner● Snitch● Replica placement

strategy● Seeds● Cassandra.yaml

Gossip ● The P2P protocol● Seed nodes● Each second● Start up

Partitioner

● Key based

A[0-3]

C[9-13]

D[14-18] B[4-8]

Jim Car: Camaro Age: 32

Carol Color: Pink Work: Hobby

Suzy Team: Bahia Country: USA

Jim 1

Carol 13

Suzy 15

Partitioner

● Hash da Chave● Murmur3Partitioner(default)● RandomPartitioner (MD5)● ByteOrderedPartitioner

Jim -2245462676723223822

Carol 7723358927203680754

Suzy 1168604627387940318

Murmur3 Partitioner

Replica placement strategy

● SimpleStrategy● NetworkTopologyStrategy

Write/Read

● Coordinator● BackGround● Read repair● Clock Vector

Types

● Text● Blob● Set● List● Map● uuid

Cassandra Query Language

● Drop● Insert● Update● Delete● SQL like

CREATE TABLE monkeySpecies (

species text PRIMARY KEY,

common_name text,

population varint,

average_size int

) WITH comment='Important

biological records'

AND read_repair_chance =

1.0;

SELECT name, occupation FROM users

WHERE userid IN (199, 200, 207);

UPDATE UserActions

SET total = total + 2

WHERE user =

B70DE1D0-9908-4AE3-BE34-5573E5B09F14

AND action = 'click';

DELETE FROM NerdMovies USING

TIMESTAMP 1240003134

WHERE movie = 'Serenity';

Using a user-defined typeCREATE TYPE

mykeyspace.address (

street text,

city text,

zip_code int,

phones set<text>

);

CREATE TYPE

mykeyspace.fullname (

firstname text,

lastname text

);

CREATE TABLE mykeyspace.users ( id uuid PRIMARY KEY, name frozen <fullname>, direct_reports set<frozen <fullname>>, // a collection set addresses map<text, frozen <address>> // a collection map);

Issues● Modeling● Search● Know-how● Know-why

Operations

Dev

Docker and Cassandra

https://hub.docker.com/_/cassandra/

JNoSQL

● Mapping API● Communication API● No lock-in● Divide and conquer

DAO

Mapping

Communication

DocumentKey

Column Graph

DIANA

ARTEMIS

JNoSQL

Data Tier

Thank You

Otávio Santana@[email protected]@apache.org