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

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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
 
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
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
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
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Dernier (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
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?
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
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?
 
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...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

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