Your SlideShare is downloading. ×
0
4: Interfacing with CassandraZubair Nabizubair.nabi@itu.edu.pkApril 20, 2013Zubair Nabi 4: Interfacing with Cassandra Apri...
Introduction1Project website: http://cassandra.apache.org/1Disclaimer: Based on the wonderful talk given by Jeremiah Jorda...
Introduction1Project website: http://cassandra.apache.org/Column based key value store (multi-level dictionary)1Disclaimer...
Introduction1Project website: http://cassandra.apache.org/Column based key value store (multi-level dictionary)Consists of...
Introduction1Project website: http://cassandra.apache.org/Column based key value store (multi-level dictionary)Consists of...
Introduction1Project website: http://cassandra.apache.org/Column based key value store (multi-level dictionary)Consists of...
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 3 / 16
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 4 / 16
Starting upRunning it: sudo cassandra -fZubair Nabi 4: Interfacing with Cassandra April 20, 2013 5 / 16
Starting upRunning it: sudo cassandra -fRunning the CLI: cassandra-cliZubair Nabi 4: Interfacing with Cassandra April 20, ...
Creating a keyspaceConnecting to the store: connect localhost/9160;Zubair Nabi 4: Interfacing with Cassandra April 20, 201...
Creating a keyspaceConnecting to the store: connect localhost/9160;Creating a keyspace: create keyspace ApplicationDatawit...
Creating a column familyReferencing a keyspace: use ApplicationData;Zubair Nabi 4: Interfacing with Cassandra April 20, 20...
Creating a column familyReferencing a keyspace: use ApplicationData;Creating a column family: create column family UserInf...
Interfacing with Cassandra in PythonPackage: pycassaZubair Nabi 4: Interfacing with Cassandra April 20, 2013 8 / 16
Interfacing with Cassandra in PythonPackage: pycassaWebpage: https://github.com/pycassa/pycassaZubair Nabi 4: Interfacing ...
Pycassa Basics1 import pycassa2 from pycassa.pool import ConnectionPool3 from pycassa.columnfamily import ColumnFamily45 p...
Read1 readData = col_fam.get(’John’,2 columns=[’email’])Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 10 / 16
Delete1 col_fam.remove(’John’,2 columns=[’email’])Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 11 / 16
Batch1 col_fam.batch_insert(2 {’John’: {’email’: ’john@gmail.com’,3 ’state’: ’IL’,4 ’gender’: ’M’},5 ’Jane’: {’email’: ’ja...
Batch Stream1 b = col_fam.batch(queue_size=10)23 b.insert(’John’,4 {’email’: ’john@gmail.com’,5 ’state’: ’IL’,6 ’gender’: ...
Batch Read1 readData = col_fam.multiget([’John’, ’Jane’, ’Bill’])Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 ...
Column Slice1 d = col_fam.get(’Jane’,2 column_start=’email’,3 column_finish=’state’)Zubair Nabi 4: Interfacing with Cassan...
Reference(s)Apache Cassandra and Python:https://pycon-2012-notes.readthedocs.org/en/latest/apache_cassandra_and_python.htm...
Upcoming SlideShare
Loading in...5
×

Lab 4: Interfacing with Cassandra

466

Published on

Cloud Computing Workshop 2013, ITU

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
466
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
27
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Lab 4: Interfacing with Cassandra"

  1. 1. 4: Interfacing with CassandraZubair Nabizubair.nabi@itu.edu.pkApril 20, 2013Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 1 / 16
  2. 2. Introduction1Project website: http://cassandra.apache.org/1Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
  3. 3. Introduction1Project website: http://cassandra.apache.org/Column based key value store (multi-level dictionary)1Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
  4. 4. Introduction1Project website: http://cassandra.apache.org/Column based key value store (multi-level dictionary)Consists of keyspaces and column families1Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
  5. 5. Introduction1Project website: http://cassandra.apache.org/Column based key value store (multi-level dictionary)Consists of keyspaces and column familiesKeyspace: Namespace for column families (typically one perapplication)1Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
  6. 6. Introduction1Project website: http://cassandra.apache.org/Column based key value store (multi-level dictionary)Consists of keyspaces and column familiesKeyspace: Namespace for column families (typically one perapplication)Column family: Contains multiple columns, each of which has a name,value, and timestamp, and which are referenced by row keys1Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
  7. 7. Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 3 / 16
  8. 8. Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 4 / 16
  9. 9. Starting upRunning it: sudo cassandra -fZubair Nabi 4: Interfacing with Cassandra April 20, 2013 5 / 16
  10. 10. Starting upRunning it: sudo cassandra -fRunning the CLI: cassandra-cliZubair Nabi 4: Interfacing with Cassandra April 20, 2013 5 / 16
  11. 11. Creating a keyspaceConnecting to the store: connect localhost/9160;Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 6 / 16
  12. 12. Creating a keyspaceConnecting to the store: connect localhost/9160;Creating a keyspace: create keyspace ApplicationDatawith placement_strategy =’org.apache.cassandra.locator.SimpleStrategy’and strategy_options =[{replication_factor:1}];Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 6 / 16
  13. 13. Creating a column familyReferencing a keyspace: use ApplicationData;Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 7 / 16
  14. 14. Creating a column familyReferencing a keyspace: use ApplicationData;Creating a column family: create column family UserInfoand comparator = ’AsciiType’;Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 7 / 16
  15. 15. Interfacing with Cassandra in PythonPackage: pycassaZubair Nabi 4: Interfacing with Cassandra April 20, 2013 8 / 16
  16. 16. Interfacing with Cassandra in PythonPackage: pycassaWebpage: https://github.com/pycassa/pycassaZubair Nabi 4: Interfacing with Cassandra April 20, 2013 8 / 16
  17. 17. Pycassa Basics1 import pycassa2 from pycassa.pool import ConnectionPool3 from pycassa.columnfamily import ColumnFamily45 pool = ConnectionPool(’ApplicationData’,6 [’localhost:9160’])7 col_fam = ColumnFamily(pool, ’UserInfo’)8 col_fam.insert(’John’, {’email’: ’john@gmail.com’})Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 9 / 16
  18. 18. Read1 readData = col_fam.get(’John’,2 columns=[’email’])Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 10 / 16
  19. 19. Delete1 col_fam.remove(’John’,2 columns=[’email’])Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 11 / 16
  20. 20. Batch1 col_fam.batch_insert(2 {’John’: {’email’: ’john@gmail.com’,3 ’state’: ’IL’,4 ’gender’: ’M’},5 ’Jane’: {’email’: ’jane@python.org’,6 ’state’: ’CA’7 ’gender’: ’M’}})Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 12 / 16
  21. 21. Batch Stream1 b = col_fam.batch(queue_size=10)23 b.insert(’John’,4 {’email’: ’john@gmail.com’,5 ’state’: ’IL’,6 ’gender’: ’M’})78 b.insert(’Jane’,9 {’email’: ’jane@python.org’,10 ’state’: ’CA’})1112 b.remove(’John’, [’gender’])13 b.remove(’Jane’)14 b.send()Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 13 / 16
  22. 22. Batch Read1 readData = col_fam.multiget([’John’, ’Jane’, ’Bill’])Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 14 / 16
  23. 23. Column Slice1 d = col_fam.get(’Jane’,2 column_start=’email’,3 column_finish=’state’)Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 15 / 16
  24. 24. Reference(s)Apache Cassandra and Python:https://pycon-2012-notes.readthedocs.org/en/latest/apache_cassandra_and_python.htmlZubair Nabi 4: Interfacing with Cassandra April 20, 2013 16 / 16
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×