SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
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

Mais conteúdo relacionado

Destaque

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
 

Destaque (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
 

Mais 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
 

Mais 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
 

Último

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
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
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 

Último (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
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...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

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