SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
4: Interfacing with Cassandra
Zubair Nabi
zubair.nabi@itu.edu.pk
April 20, 2013
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 1 / 16
Introduction1
Project website: http://cassandra.apache.org/
1
Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
Introduction1
Project website: http://cassandra.apache.org/
Column based key value store (multi-level dictionary)
1
Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
Introduction1
Project website: http://cassandra.apache.org/
Column based key value store (multi-level dictionary)
Consists of keyspaces and column families
1
Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
Introduction1
Project website: http://cassandra.apache.org/
Column based key value store (multi-level dictionary)
Consists of keyspaces and column families
Keyspace: Namespace for column families (typically one per
application)
1
Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
Introduction1
Project website: http://cassandra.apache.org/
Column based key value store (multi-level dictionary)
Consists of keyspaces and column families
Keyspace: Namespace for column families (typically one per
application)
Column family: Contains multiple columns, each of which has a name,
value, and timestamp, and which are referenced by row keys
1
Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 3 / 16
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 4 / 16
Starting up
Running it: sudo cassandra -f
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 5 / 16
Starting up
Running it: sudo cassandra -f
Running the CLI: cassandra-cli
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 5 / 16
Creating a keyspace
Connecting to the store: connect localhost/9160;
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 6 / 16
Creating a keyspace
Connecting to the store: connect localhost/9160;
Creating a keyspace: create keyspace ApplicationData
with placement_strategy =
’org.apache.cassandra.locator.SimpleStrategy’
and strategy_options =
[{replication_factor:1}];
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 6 / 16
Creating a column family
Referencing a keyspace: use ApplicationData;
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 7 / 16
Creating a column family
Referencing a keyspace: use ApplicationData;
Creating a column family: create column family UserInfo
and comparator = ’AsciiType’;
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 7 / 16
Interfacing with Cassandra in Python
Package: pycassa
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 8 / 16
Interfacing with Cassandra in Python
Package: pycassa
Webpage: https://github.com/pycassa/pycassa
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 8 / 16
Pycassa Basics
1 import pycassa
2 from pycassa.pool import ConnectionPool
3 from pycassa.columnfamily import ColumnFamily
4
5 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
Read
1 readData = col_fam.get(’John’,
2 columns=[’email’])
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 10 / 16
Delete
1 col_fam.remove(’John’,
2 columns=[’email’])
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 11 / 16
Batch
1 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
Batch Stream
1 b = col_fam.batch(queue_size=10)
2
3 b.insert(’John’,
4 {’email’: ’john@gmail.com’,
5 ’state’: ’IL’,
6 ’gender’: ’M’})
7
8 b.insert(’Jane’,
9 {’email’: ’jane@python.org’,
10 ’state’: ’CA’})
11
12 b.remove(’John’, [’gender’])
13 b.remove(’Jane’)
14 b.send()
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 13 / 16
Batch Read
1 readData = col_fam.multiget([’John’, ’Jane’, ’Bill’])
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 14 / 16
Column Slice
1 d = col_fam.get(’Jane’,
2 column_start=’email’,
3 column_finish=’state’)
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 15 / 16
Reference(s)
Apache Cassandra and Python:
https://pycon-2012-notes.readthedocs.org/en/
latest/apache_cassandra_and_python.html
Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 16 / 16

Contenu connexe

En vedette

AOS Lab 4: If you liked it, then you should have put a “lock” on it
AOS Lab 4: If you liked it, then you should have put a “lock” on itAOS Lab 4: If you liked it, then you should have put a “lock” on it
AOS Lab 4: If you liked it, then you should have put a “lock” on itZubair Nabi
 
MapReduce Application Scripting
MapReduce Application ScriptingMapReduce Application Scripting
MapReduce Application ScriptingZubair Nabi
 
Lab 1: Introduction to Amazon EC2 and MPI
Lab 1: Introduction to Amazon EC2 and MPILab 1: Introduction to Amazon EC2 and MPI
Lab 1: Introduction to Amazon EC2 and MPIZubair Nabi
 
AOS Lab 6: Scheduling
AOS Lab 6: SchedulingAOS Lab 6: Scheduling
AOS Lab 6: SchedulingZubair Nabi
 
AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!Zubair Nabi
 
AOS Lab 8: Interrupts and Device Drivers
AOS Lab 8: Interrupts and Device DriversAOS Lab 8: Interrupts and Device Drivers
AOS Lab 8: Interrupts and Device DriversZubair Nabi
 
AOS Lab 5: System calls
AOS Lab 5: System callsAOS Lab 5: System calls
AOS Lab 5: System callsZubair Nabi
 
Topic 13: Cloud Stacks
Topic 13: Cloud StacksTopic 13: Cloud Stacks
Topic 13: Cloud StacksZubair Nabi
 
Topic 8: Enhancements and Alternative Architectures
Topic 8: Enhancements and Alternative ArchitecturesTopic 8: Enhancements and Alternative Architectures
Topic 8: Enhancements and Alternative ArchitecturesZubair Nabi
 
The Anatomy of Web Censorship in Pakistan
The Anatomy of Web Censorship in PakistanThe Anatomy of Web Censorship in Pakistan
The Anatomy of Web Censorship in PakistanZubair Nabi
 
Topic 7: Shortcomings in the MapReduce Paradigm
Topic 7: Shortcomings in the MapReduce ParadigmTopic 7: Shortcomings in the MapReduce Paradigm
Topic 7: Shortcomings in the MapReduce ParadigmZubair Nabi
 
Lab 3: Writing a Naiad Application
Lab 3: Writing a Naiad ApplicationLab 3: Writing a Naiad Application
Lab 3: Writing a Naiad ApplicationZubair Nabi
 
Topic 5: MapReduce Theory and Implementation
Topic 5: MapReduce Theory and ImplementationTopic 5: MapReduce Theory and Implementation
Topic 5: MapReduce Theory and ImplementationZubair Nabi
 
AOS Lab 11: Virtualization
AOS Lab 11: VirtualizationAOS Lab 11: Virtualization
AOS Lab 11: VirtualizationZubair Nabi
 
Topic 1: Big Data and Warehouse-scale Computing
Topic 1: Big Data and Warehouse-scale ComputingTopic 1: Big Data and Warehouse-scale Computing
Topic 1: Big Data and Warehouse-scale ComputingZubair Nabi
 
Topic 12: NoSQL in Action
Topic 12: NoSQL in ActionTopic 12: NoSQL in Action
Topic 12: NoSQL in ActionZubair Nabi
 
The Big Data Stack
The Big Data StackThe Big Data Stack
The Big Data StackZubair Nabi
 
Topic 14: Operating Systems and Virtualization
Topic 14: Operating Systems and VirtualizationTopic 14: Operating Systems and Virtualization
Topic 14: Operating Systems and VirtualizationZubair Nabi
 
AOS Lab 10: File system -- Inodes and beyond
AOS Lab 10: File system -- Inodes and beyondAOS Lab 10: File system -- Inodes and beyond
AOS Lab 10: File system -- Inodes and beyondZubair Nabi
 

En vedette (20)

AOS Lab 4: If you liked it, then you should have put a “lock” on it
AOS Lab 4: If you liked it, then you should have put a “lock” on itAOS Lab 4: If you liked it, then you should have put a “lock” on it
AOS Lab 4: If you liked it, then you should have put a “lock” on it
 
MapReduce Application Scripting
MapReduce Application ScriptingMapReduce Application Scripting
MapReduce Application Scripting
 
Lab 1: Introduction to Amazon EC2 and MPI
Lab 1: Introduction to Amazon EC2 and MPILab 1: Introduction to Amazon EC2 and MPI
Lab 1: Introduction to Amazon EC2 and MPI
 
AOS Lab 6: Scheduling
AOS Lab 6: SchedulingAOS Lab 6: Scheduling
AOS Lab 6: Scheduling
 
AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!
 
AOS Lab 8: Interrupts and Device Drivers
AOS Lab 8: Interrupts and Device DriversAOS Lab 8: Interrupts and Device Drivers
AOS Lab 8: Interrupts and Device Drivers
 
AOS Lab 5: System calls
AOS Lab 5: System callsAOS Lab 5: System calls
AOS Lab 5: System calls
 
Topic 13: Cloud Stacks
Topic 13: Cloud StacksTopic 13: Cloud Stacks
Topic 13: Cloud Stacks
 
Topic 8: Enhancements and Alternative Architectures
Topic 8: Enhancements and Alternative ArchitecturesTopic 8: Enhancements and Alternative Architectures
Topic 8: Enhancements and Alternative Architectures
 
The Anatomy of Web Censorship in Pakistan
The Anatomy of Web Censorship in PakistanThe Anatomy of Web Censorship in Pakistan
The Anatomy of Web Censorship in Pakistan
 
Topic 7: Shortcomings in the MapReduce Paradigm
Topic 7: Shortcomings in the MapReduce ParadigmTopic 7: Shortcomings in the MapReduce Paradigm
Topic 7: Shortcomings in the MapReduce Paradigm
 
Lab 3: Writing a Naiad Application
Lab 3: Writing a Naiad ApplicationLab 3: Writing a Naiad Application
Lab 3: Writing a Naiad Application
 
Topic 5: MapReduce Theory and Implementation
Topic 5: MapReduce Theory and ImplementationTopic 5: MapReduce Theory and Implementation
Topic 5: MapReduce Theory and Implementation
 
AOS Lab 11: Virtualization
AOS Lab 11: VirtualizationAOS Lab 11: Virtualization
AOS Lab 11: Virtualization
 
Topic 1: Big Data and Warehouse-scale Computing
Topic 1: Big Data and Warehouse-scale ComputingTopic 1: Big Data and Warehouse-scale Computing
Topic 1: Big Data and Warehouse-scale Computing
 
Topic 9: MR+
Topic 9: MR+Topic 9: MR+
Topic 9: MR+
 
Topic 12: NoSQL in Action
Topic 12: NoSQL in ActionTopic 12: NoSQL in Action
Topic 12: NoSQL in Action
 
The Big Data Stack
The Big Data StackThe Big Data Stack
The Big Data Stack
 
Topic 14: Operating Systems and Virtualization
Topic 14: Operating Systems and VirtualizationTopic 14: Operating Systems and Virtualization
Topic 14: Operating Systems and Virtualization
 
AOS Lab 10: File system -- Inodes and beyond
AOS Lab 10: File system -- Inodes and beyondAOS Lab 10: File system -- Inodes and beyond
AOS Lab 10: File system -- Inodes and beyond
 

Plus de Zubair Nabi

AOS Lab 12: Network Communication
AOS Lab 12: Network CommunicationAOS Lab 12: Network Communication
AOS Lab 12: Network CommunicationZubair Nabi
 
AOS Lab 7: Page tables
AOS Lab 7: Page tablesAOS Lab 7: Page tables
AOS Lab 7: Page tablesZubair Nabi
 
AOS Lab 2: Hello, xv6!
AOS Lab 2: Hello, xv6!AOS Lab 2: Hello, xv6!
AOS Lab 2: Hello, xv6!Zubair Nabi
 
Raabta: Low-cost Video Conferencing for the Developing World
Raabta: Low-cost Video Conferencing for the Developing WorldRaabta: Low-cost Video Conferencing for the Developing World
Raabta: Low-cost Video Conferencing for the Developing WorldZubair Nabi
 
Topic 15: Datacenter Design and Networking
Topic 15: Datacenter Design and NetworkingTopic 15: Datacenter Design and Networking
Topic 15: Datacenter Design and NetworkingZubair Nabi
 
Lab 5: Interconnecting a Datacenter using Mininet
Lab 5: Interconnecting a Datacenter using MininetLab 5: Interconnecting a Datacenter using Mininet
Lab 5: Interconnecting a Datacenter using MininetZubair Nabi
 
Topic 10: Taxonomy of Data and Storage
Topic 10: Taxonomy of Data and StorageTopic 10: Taxonomy of Data and Storage
Topic 10: Taxonomy of Data and StorageZubair Nabi
 
Topic 6: MapReduce Applications
Topic 6: MapReduce ApplicationsTopic 6: MapReduce Applications
Topic 6: MapReduce ApplicationsZubair Nabi
 

Plus de Zubair Nabi (8)

AOS Lab 12: Network Communication
AOS Lab 12: Network CommunicationAOS Lab 12: Network Communication
AOS Lab 12: Network Communication
 
AOS Lab 7: Page tables
AOS Lab 7: Page tablesAOS Lab 7: Page tables
AOS Lab 7: Page tables
 
AOS Lab 2: Hello, xv6!
AOS Lab 2: Hello, xv6!AOS Lab 2: Hello, xv6!
AOS Lab 2: Hello, xv6!
 
Raabta: Low-cost Video Conferencing for the Developing World
Raabta: Low-cost Video Conferencing for the Developing WorldRaabta: Low-cost Video Conferencing for the Developing World
Raabta: Low-cost Video Conferencing for the Developing World
 
Topic 15: Datacenter Design and Networking
Topic 15: Datacenter Design and NetworkingTopic 15: Datacenter Design and Networking
Topic 15: Datacenter Design and Networking
 
Lab 5: Interconnecting a Datacenter using Mininet
Lab 5: Interconnecting a Datacenter using MininetLab 5: Interconnecting a Datacenter using Mininet
Lab 5: Interconnecting a Datacenter using Mininet
 
Topic 10: Taxonomy of Data and Storage
Topic 10: Taxonomy of Data and StorageTopic 10: Taxonomy of Data and Storage
Topic 10: Taxonomy of Data and Storage
 
Topic 6: MapReduce Applications
Topic 6: MapReduce ApplicationsTopic 6: MapReduce Applications
Topic 6: MapReduce Applications
 

Dernier

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Dernier (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

Lab 4: Interfacing with Cassandra

  • 1. 4: Interfacing with Cassandra Zubair Nabi zubair.nabi@itu.edu.pk April 20, 2013 Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 1 / 16
  • 2. Introduction1 Project website: http://cassandra.apache.org/ 1 Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012 Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
  • 3. Introduction1 Project website: http://cassandra.apache.org/ Column based key value store (multi-level dictionary) 1 Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012 Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
  • 4. Introduction1 Project website: http://cassandra.apache.org/ Column based key value store (multi-level dictionary) Consists of keyspaces and column families 1 Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012 Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
  • 5. Introduction1 Project website: http://cassandra.apache.org/ Column based key value store (multi-level dictionary) Consists of keyspaces and column families Keyspace: Namespace for column families (typically one per application) 1 Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012 Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
  • 6. Introduction1 Project website: http://cassandra.apache.org/ Column based key value store (multi-level dictionary) Consists of keyspaces and column families Keyspace: Namespace for column families (typically one per application) Column family: Contains multiple columns, each of which has a name, value, and timestamp, and which are referenced by row keys 1 Disclaimer: Based on the wonderful talk given by Jeremiah Jordan at PyCon 2012 Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 2 / 16
  • 7. Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 3 / 16
  • 8. Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 4 / 16
  • 9. Starting up Running it: sudo cassandra -f Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 5 / 16
  • 10. Starting up Running it: sudo cassandra -f Running the CLI: cassandra-cli Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 5 / 16
  • 11. Creating a keyspace Connecting to the store: connect localhost/9160; Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 6 / 16
  • 12. Creating a keyspace Connecting to the store: connect localhost/9160; Creating a keyspace: create keyspace ApplicationData with 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. Creating a column family Referencing a keyspace: use ApplicationData; Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 7 / 16
  • 14. Creating a column family Referencing a keyspace: use ApplicationData; Creating a column family: create column family UserInfo and comparator = ’AsciiType’; Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 7 / 16
  • 15. Interfacing with Cassandra in Python Package: pycassa Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 8 / 16
  • 16. Interfacing with Cassandra in Python Package: pycassa Webpage: https://github.com/pycassa/pycassa Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 8 / 16
  • 17. Pycassa Basics 1 import pycassa 2 from pycassa.pool import ConnectionPool 3 from pycassa.columnfamily import ColumnFamily 4 5 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. Read 1 readData = col_fam.get(’John’, 2 columns=[’email’]) Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 10 / 16
  • 19. Delete 1 col_fam.remove(’John’, 2 columns=[’email’]) Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 11 / 16
  • 20. Batch 1 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. Batch Stream 1 b = col_fam.batch(queue_size=10) 2 3 b.insert(’John’, 4 {’email’: ’john@gmail.com’, 5 ’state’: ’IL’, 6 ’gender’: ’M’}) 7 8 b.insert(’Jane’, 9 {’email’: ’jane@python.org’, 10 ’state’: ’CA’}) 11 12 b.remove(’John’, [’gender’]) 13 b.remove(’Jane’) 14 b.send() Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 13 / 16
  • 22. Batch Read 1 readData = col_fam.multiget([’John’, ’Jane’, ’Bill’]) Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 14 / 16
  • 23. Column Slice 1 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. Reference(s) Apache Cassandra and Python: https://pycon-2012-notes.readthedocs.org/en/ latest/apache_cassandra_and_python.html Zubair Nabi 4: Interfacing with Cassandra April 20, 2013 16 / 16