Introduction To Cassandra
Introduction To Cassandra
Introduction To Cassandra
Introduction to Cassandra
Learning Objectives and Learning Outcomes
e) To be able to successfully
export to CSV.
Session Plan
Q/A 15 minutes
Agenda
Apache Cassandra was born at Facebook. After Facebook open sourced the
code in 2008, Cassandra became an Apache Incubator project in 2009 and
subsequently became a top-level Apache project in 2010.
• Open Source
• Distributed
• Column-oriented
• Peer to Peer
• Elastic Scalability
Peer to Peer Network
Sample Cassandra Cluster
Writes in Cassandra
Writes in Cassandra
The next step is to push the write to a memory resident data structure
called Memtable. A threshold value is defined in the Memtable.
Coordinator
Node C is down.
Write a hint in your table
A
Writes Row K
C
Tunable Consistency
Read Consistency
BEGIN BATCH
INSERT INTO student_info
(RollNo,StudName,DateofJoining,LastExamPercent)
VALUES (1,'Michael Storm','2012-03-29', 69.6)
INSERT INTO student_info
(RollNo,StudName,DateofJoining,LastExamPercent)
VALUES (2,'Stephen Fox','2013-02-27', 72.5)
APPLY BATCH;
CRUD - Select
SELECT *
FROM student_info;
CRUD – Create Index
Note: An update updates one or more column values for a given row to the
Cassandra table. It does not return anything.
Note: Delete statement removes one or more columns from one or more
rows of a Cassandra table or removes entire rows if no columns are specified.
DELETE LastExamPercent FROM student_info WHERE RollNo=2;
Collections
Collections
To alter the schema for the table “student_info” to add a column “hobbies”.
To update the table “student_info” to provide the values for “hobbies” for the
student with Rollno =1.
UPDATE student_info
SET hobbies = hobbies + {'Chess, Table Tennis'}
WHERE RollNo=1;
Collections - List
To alter the schema of the table “student_info” to add a list column “language”.
ALTER TABLE student_info ADD language list<text>;
Collections - List
UPDATE student_info
SET language = language + ['Hindi, English']
WHERE RollNo=1;
Collections - Map
To update the record for user (user_id = ‘AB’) in the “users” table.
UPDATE users
SET todo =
{ ‘2014-9-24’: ‘Cassandra Session’,
‘2014-10-2 12:00’ : ‘MongoDB Session’ }
WHERE user_id = ‘AB’;
Time To Live
Time To Live
Data in a column, other than a counter column, can have an optional expiration period called
TTL (time to live). The client request may specify a TTL value for the data. The TTL is
specified in seconds.
INSERT INTO userlogin (userid, password) VALUES (1,'infy') USING TTL 30;
What is Cassandra?
Comment on Cassandra writes.
What is your understanding of tunable consistency?
What are collections in CQLSH? Where are they used?
Summary please…
http://www.datastax.com/documentation/cassandra/2.0/cassandra/gettingS
tartedCassandraIntro.html
http://www.datastax.com/documentation/cql/3.1/pdf/cql31.pdf
http://www.datastax.com/documentation/cassandra/2.0/cassandra/dml/dm
l_config_consistency_c.html
Thank you