Building Java Applications  with  Apache Cassandra Nate McCall [email_address] @zznate
What is Apache Cassandra?
CAP Theorem  C onsistency A vailability  P artition Tolerance “ Thou shalt have but 2”  - Conjecture made by Eric Brewer in 2000 - Published as formal proof in 2002 - See:  http://en.wikipedia.org/wiki/CAP_theorem  for more
Apache Cassandra Concepts - Explicit choice of partition tolerance and availability. Consistency is tunable. - No read before write - Merge on read - Idempotent - Schema Optional - All nodes share the same role - Still performs well with larger-than-memory data sets
Generally complements another system(s)  (Not intended to be one-size-fits-all) *** You should always use the right tool for the right job anyway
How does this differ from an RDBMS?
How does this differ from an RDBMS? Substantially.
vs. RDBMS - No Joins  Unless:  - you do them on the client  - you do them via Map/Reduce
vs. RDBMS - Schema Optional  (Though you can add meta information for validation and type checking)  *** Supports secondary indexes too: “ …  WHERE state = 'TX' ”
vs. RDBMS - Prematerialized and Transaction-less - No ACID transactions  - Limited support for ad-hoc queries
vs. RDBMS - Prematerialized and Transaction-less - No ACID transactions  - Limited support for ad-hoc queries *** You are going to give up both of these anyway when you shard an RDBMS ***
vs. RDBMS - Facilitates Consolidation It can be your caching layer * Off-heap cache (provided you install JNA) It can be your analytics infrastructure * true map/reduce * pig driver * hive driver coming soon
vs. RDBMS - Shared-Nothing Architecture Every node plays the same role: no masters, no slaves, no special nodes *** No single point of failure
vs. RDBMS - Real Linear Scalability Want 2x performance? Add 2x nodes. *** 'No downtime' included!
vs. RDBMS - Performance Reads on par with writes
Storage (Briefly)
Storage (Briefly)  Understanding the on-disk format is extremely helpful in designing your data model correctly
Storage - SSTable - SSTables are immutable (“Merge on read”) - Newest timestamp wins
Storage – Compaction Merge SSTables – keeping count down making Merge on Read more efficient Discards Tombstones (more on this later!)
Data Model
Data Model "...sparse, persistent, distributed, multi-dimensional sorted map." (The “Bigtable” paper)
Data Model Keyspace - Collection of Column Families
- Controls replication
Column Family
- Similar to a table
- Columns ordered by name
Data Model – Column Family Static Column Family - Model my object data
Dynamic Column Family
- Pre-calculated query results
Nothing stopping you from mixing them!
Data Model – Static CF GOOG AAPL NFLX NOK price: 589.55 price: 401.76 price: 78.73 name : Google name : Apple name : Netflix price: 6.90 name : Nokia exchange : NYSE Stocks
Data Model – Prematerialized Query StockHist 10/25/2011: 6.71 GOOG AAPL NFLX NOK 10/24/2011: 6.76 10/21/2011: 6.61 10/25/2011: 77.37 10/24/2011: 118.84 10/21/2011: 117.04 10/25/2011: 397.77 10/24/2011: 405.77 10/21/2011: 392.87 10/25/2011: 583.16 10/24/2011: 596.42 10/21/2011: 590.49
API Operations
Five general categories Retrieving Writing/Updating/Removing (all the same op!) Increment counters Meta Information Schema Manipulation CQL Execution
Using a Client Hector Client: http://hector-client.org - Most popular Java client  - In use at very large installations - A number of tools and utilities built on top - Very active community - MIT Licensed  *** like any open source project fully dependent on another open source project it has its worts
Sample Project for Experimenting https://github.com/zznate/cassandra-tutorial https://github.com/zznate/hector-examples Built using Hector  Really basic – designed to be beginner level w/ very few moving parts Modify/abuse/alter as needed *** Descriptions of what is going on and how to run each example are in the Javadoc comments. 
ColumnFamilyTemplate Familiar, type-safe approach - based on template-method design pattern - generic: ColumnFamilyTemplate<K,N> (K is the key type, N the column name type) ColumnFamilyTemplate template = new ThriftColumnFamilyTemplate(keyspaceName,  columnFamilyName,  StringSerializer.get(),  StringSerializer.get()); *** (no generics for clarity)
ColumnFamilyTemplate new ThriftColumnFamilyTemplate(keyspaceName,  columnFamilyName,  StringSerializer.get(),  StringSerializer.get()); Key Format Column Name Format - Cassandra calls this a “comparator” - Remember: defines column order in on-disk format
ColumnFamilyTemplate ColumnFamilyResult<String, String> res = cft.queryColumns(&quot;zznate&quot;); String value = res.getString(&quot;email&quot;); Date startDate = res.getDate(“startDate”); Key Format Column Name Format
ColumnFamilyTemplate ColumnFamilyResult wrapper =  template.queryColumns(&quot;GOOG&quot;, &quot;AAPL&quot;, &quot;NFLX&quot;); String googName = wrapper.getString(&quot;name&quot;);  wrapper.next(); String aaplName = wrapper.getString(&quot;name&quot;); wrapper.next(); String  nflxName = wrapper.getString(&quot;name&quot;); Querying multiple rows and iterating over results
ColumnFamilyTemplate ColumnFamilyUpdater updater = template.createUpdater(&quot;AAPL&quot;);  updater.setString(&quot;exchange&quot;,&quot;NASDAQ&quot;); updater.addKey(&quot;GOOG&quot;); updater.setString(&quot;exchange&quot;,&quot;NASDAQ&quot;); template.update(updater); Inserting data with ColumnFamilyUpdater
ColumnFamilyTemplate template.deleteColumn(&quot;AAPL&quot;, &quot;notNeededStuff&quot;); template.deleteColumn(&quot;GOOG&quot;, &quot;somethingElse&quot;); template.deleteColumn(&quot;GOOG&quot;, &quot;aDifferentColumnName&quot;); ... template.deleteRow(“NOK”); template.executeBatch(); Deleting Data with ColumnFamilyTemplate
Deletion
Deletion Again: Every mutation is an insert!
- Merge on read
- Sstables are immutable
- Highest timestamp wins
Deletion – As Seen by CLI [default@Tutorial] list StateCity; Using default limit of 100
-------------------
RowKey: CA Burlingame
=> (column=650, value=33372e3537783132322e3334, timestamp=1310340410528000)
-------------------
RowKey: TX Austin
=> (column=202, value=33302e3237783039372e3734, timestamp=1310143852392000)
=> (column=203, value=33302e3237783039372e3734, timestamp=1310143852444000)
=> (column=204, value=33302e3332783039372e3733, timestamp=1310143852448000)
=> (column=205, value=33302e3332783039372e3733, timestamp=1310143852453000)
=> (column=206, value=33302e3332783039372e3733, timestamp=1310143852457000)
Deletion – As Seen by CLI [default@Tutorial] list StateCity; Using default limit of 100

More Related Content

PDF
Stampede con 2014 cassandra in the real world
ODP
Meetup cassandra sfo_jdbc
PPT
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
PPTX
Understanding DSE Search by Matt Stump
PDF
Compliance as Code with terraform-compliance
PDF
MySQL under the siege
PDF
Static Typing in Vault
PDF
DEVIEW - 오픈소스를 활용한 분산아키텍처 구현기술
Stampede con 2014 cassandra in the real world
Meetup cassandra sfo_jdbc
Hector v2: The Second Version of the Popular High-Level Java Client for Apach...
Understanding DSE Search by Matt Stump
Compliance as Code with terraform-compliance
MySQL under the siege
Static Typing in Vault
DEVIEW - 오픈소스를 활용한 분산아키텍처 구현기술

What's hot (20)

PDF
[263] s2graph large-scale-graph-database-with-hbase-2
PPTX
DataStax: An Introduction to DataStax Enterprise Search
PDF
C* Summit EU 2013: Cassandra Internals
PDF
Terraforming RDS
PDF
Introduction to rest.li
PPTX
Async servers and clients in Rest.li
PPTX
Creating Reusable Puppet Profiles
PDF
Manchester Hadoop Meetup: Cassandra Spark internals
PDF
Fluentd and Embulk Game Server 4
PPTX
It's 10pm: Do You Know Where Your Writes Are?
PDF
Nuvola: a tale of migration to AWS
PDF
How to build a High Performance PSGI/Plack Server
PPTX
Kubernetes #4 volume &amp; stateful set
PDF
Incrementalism: An Industrial Strategy For Adopting Modern Automation
PPTX
DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...
PDF
Taming the Cloud Database with Apache jclouds
PDF
FwDays 2021: Metarhia Technology Stack for Node.js
PDF
Creating PostgreSQL-as-a-Service at Scale
PDF
vert.x 소개 및 개발 실습
PDF
Gimme Caching - The JCache Way
[263] s2graph large-scale-graph-database-with-hbase-2
DataStax: An Introduction to DataStax Enterprise Search
C* Summit EU 2013: Cassandra Internals
Terraforming RDS
Introduction to rest.li
Async servers and clients in Rest.li
Creating Reusable Puppet Profiles
Manchester Hadoop Meetup: Cassandra Spark internals
Fluentd and Embulk Game Server 4
It's 10pm: Do You Know Where Your Writes Are?
Nuvola: a tale of migration to AWS
How to build a High Performance PSGI/Plack Server
Kubernetes #4 volume &amp; stateful set
Incrementalism: An Industrial Strategy For Adopting Modern Automation
DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...
Taming the Cloud Database with Apache jclouds
FwDays 2021: Metarhia Technology Stack for Node.js
Creating PostgreSQL-as-a-Service at Scale
vert.x 소개 및 개발 실습
Gimme Caching - The JCache Way
Ad

Similar to Meetup cassandra for_java_cql (20)

ODP
Introduciton to Apache Cassandra for Java Developers (JavaOne)
ODP
Nyc summit intro_to_cassandra
ODP
Introduction to apache_cassandra_for_developers-lhg
DOCX
Cassandra data modelling best practices
PPTX
Cassandra's Sweet Spot - an introduction to Apache Cassandra
PPTX
Cassandra20141113
PPTX
Introduction to Apache Cassandra and support within WSO2 Platform
PPT
Introduction to apache_cassandra_for_develope
PPTX
Introduction to cassandra
ODP
Intro to cassandra
PPTX
Cassandra20141009
PPTX
Using Cassandra with your Web Application
PPTX
Learning Cassandra NoSQL
PPT
Scaling Web Applications with Cassandra Presentation (1).ppt
PPTX
C*ollege Credit: Creating Your First App in Java with Cassandra
PPTX
Apache Cassandra
PDF
Spark & Cassandra - DevFest Córdoba
PPTX
Cassandra - A decentralized storage system
PDF
Trivadis TechEvent 2016 Big Data Cassandra, wieso brauche ich das? by Jan Ott
PDF
About "Apache Cassandra"
Introduciton to Apache Cassandra for Java Developers (JavaOne)
Nyc summit intro_to_cassandra
Introduction to apache_cassandra_for_developers-lhg
Cassandra data modelling best practices
Cassandra's Sweet Spot - an introduction to Apache Cassandra
Cassandra20141113
Introduction to Apache Cassandra and support within WSO2 Platform
Introduction to apache_cassandra_for_develope
Introduction to cassandra
Intro to cassandra
Cassandra20141009
Using Cassandra with your Web Application
Learning Cassandra NoSQL
Scaling Web Applications with Cassandra Presentation (1).ppt
C*ollege Credit: Creating Your First App in Java with Cassandra
Apache Cassandra
Spark & Cassandra - DevFest Córdoba
Cassandra - A decentralized storage system
Trivadis TechEvent 2016 Big Data Cassandra, wieso brauche ich das? by Jan Ott
About "Apache Cassandra"
Ad

More from zznate (11)

PDF
Advanced Apache Cassandra Operations with JMX
PDF
Hardening cassandra q2_2016
PDF
Seattle C* Meetup: Hardening cassandra for compliance or paranoia
PDF
Software Development with Apache Cassandra
PDF
Hardening cassandra for compliance or paranoia
PDF
Successful Software Development with Apache Cassandra
PDF
An Introduction to the Vert.x framework
PDF
Intravert atx meetup_condensed
PDF
Apachecon cassandra transport
KEY
Oscon 2012 tdd_cassandra
PPTX
Strata west 2012_java_cassandra
Advanced Apache Cassandra Operations with JMX
Hardening cassandra q2_2016
Seattle C* Meetup: Hardening cassandra for compliance or paranoia
Software Development with Apache Cassandra
Hardening cassandra for compliance or paranoia
Successful Software Development with Apache Cassandra
An Introduction to the Vert.x framework
Intravert atx meetup_condensed
Apachecon cassandra transport
Oscon 2012 tdd_cassandra
Strata west 2012_java_cassandra

Recently uploaded (20)

DOCX
search engine optimization ppt fir known well about this
PDF
Zenith AI: Advanced Artificial Intelligence
PPTX
Tartificialntelligence_presentation.pptx
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
Modernising the Digital Integration Hub
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
August Patch Tuesday
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
The various Industrial Revolutions .pptx
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PPTX
Web Crawler for Trend Tracking Gen Z Insights.pptx
PDF
Architecture types and enterprise applications.pdf
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
WOOl fibre morphology and structure.pdf for textiles
search engine optimization ppt fir known well about this
Zenith AI: Advanced Artificial Intelligence
Tartificialntelligence_presentation.pptx
Chapter 5: Probability Theory and Statistics
Modernising the Digital Integration Hub
DP Operators-handbook-extract for the Mautical Institute
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Univ-Connecticut-ChatGPT-Presentaion.pdf
Enhancing emotion recognition model for a student engagement use case through...
August Patch Tuesday
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Developing a website for English-speaking practice to English as a foreign la...
Hindi spoken digit analysis for native and non-native speakers
The various Industrial Revolutions .pptx
NewMind AI Weekly Chronicles – August ’25 Week III
Web Crawler for Trend Tracking Gen Z Insights.pptx
Architecture types and enterprise applications.pdf
1 - Historical Antecedents, Social Consideration.pdf
WOOl fibre morphology and structure.pdf for textiles

Meetup cassandra for_java_cql