SlideShare une entreprise Scribd logo
1  sur  50
Télécharger pour lire hors ligne
CQL: Then, Now, and
                                When

                                  Eric Evans
                              eric@acunu.com

                              Cassandra Europe
                               March 28, 2012


Wednesday, March 28, 12
Cassandra Query Language
                                  (aka CQL)


                   • Query language for Apache Cassandra
                   • SQL for the most part
                   • An alternative query interface
                   • Available since Cassandra 0.8.0

Wednesday, March 28, 12
Wednesday, March 28, 12
Wednesday, March 28, 12
Best Troll Ever?
Wednesday, March 28, 12
Not a troll at all,
                             actually.


Wednesday, March 28, 12
Status Quo
                   • RPC-based query interface
                   • Low level; very little abstraction
                   • Implemented in Thrift
                    • Compact binary serialization
                    • Loads of supported languages
                    • Generated language code
Wednesday, March 28, 12
Unstable
                                                $@#*!
                          Relax


                                              NOT AGAIN!


                It’ll take you 5 minutes to
                      update your code.

Wednesday, March 28, 12
Not User Friendly




Wednesday, March 28, 12
This cannot be unseen!
      // Your column
      Column col = new Column(ByteBuffer.wrap(“name”.getBytes()));
      col.setValue(ByteBuffer.wrap(“value”.getBytes()));
      col.setTimestamp(System.currentTimeMillis());

      // Don’t ask
      ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();
      cosc.setColumn(cosc);

      // Hang on, here we go...
      Mutation mutation = new Mutation();
      mutation.setColumnOrSuperColumn(cosc);

      List<Mutation> mutations = new ArrayList<Mutation>();
      mutations.add(mutation);

      Map mutations_map = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
      Map cf_map = new Map<String, List<Mutation>>();
      cf_map.set(“Standard1”, mutations);
      mutations_map.put(ByteBuffer.wrap(“key”.getBytes()), cf_map);

      cassandra.batch_mutate(mutations_map, consistency_level);




Wednesday, March 28, 12
This cannot be unseen!
      // Your column
      Column col = new Column(ByteBuffer.wrap(“name”.getBytes()));
      col.setValue(ByteBuffer.wrap(“value”.getBytes()));
      col.setTimestamp(System.currentTimeMillis());

      // Don’t ask
      ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();
      cosc.setColumn(cosc);

      // Hang on, here we go...
      Mutation mutation = new Mutation();
      mutation.setColumnOrSuperColumn(cosc);

      List<Mutation> mutations = new ArrayList<Mutation>();
      mutations.add(mutation);

      Map mutations_map = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
      Map cf_map = new Map<String, List<Mutation>>();
      cf_map.set(“Standard1”, mutations);
      mutations_map.put(ByteBuffer.wrap(“key”.getBytes()), cf_map);

      cassandra.batch_mutate(mutations_map, consistency_level);




Wednesday, March 28, 12
A query interface
                               should be...
                          Simple
                          Intuitive
                          Invisible
                          Performant(?)




Wednesday, March 28, 12
Alternatives

                   • REST
                   • RPC (Thrift, Avro, Protobuf, etc)
                   • SQL (bahahaha)
                   • etc, etc

Wednesday, March 28, 12
REST
                                Pros                        Cons
                    •     Ubiquitous             •   Fails expectations

                    •     Frequently requested   •   Slow

                    •     Client uniformity




Wednesday, March 28, 12
RPC
                               Pros                    Cons
                    •     Easy to implement   •   Poor mental fit

                    •     Performant          •   Heavy dependency




Wednesday, March 28, 12
SQL
                                Pros                      Cons
                    •     Ubiquitous            •   People whinging

                    •     Widely known          •   Security(?)

                    •     Excellent mental fit

                    •     Client uniformity




Wednesday, March 28, 12
SQL
                                Pros                      Cons
                    •     Ubiquitous            •   People whinging

                    •     Widely known          •   Security(?)

                    •     Excellent mental fit

                    •     Client uniformity




Wednesday, March 28, 12
Wednesday, March 28, 12
Hello...
      -- Create or update
      INSERT INTO users (id, given, surname)
          VALUES (jericevans, Eric, Evans);

      -- Create or update
      UPDATE users SET given = Eric,
          surname = Evans WHERE id = jericevans;

      SELECT surname, given FROM users
          WHERE id = jericevans;


Wednesday, March 28, 12
...is it me you’re looking
                                      for?
      -- Adding an index
      CREATE INDEX surnameidx ON users (surname);

      SELECT id, given FROM users
          WHERE surname = Evans;

      -- Limiting the number of rows
      SELECT id, given FROM users
          WHERE surname = Evans LIMIT 1000;



Wednesday, March 28, 12
Querying column ranges
      -- From column, to column
      SELECT ‘2012-01-01’..’2012-03-28’ FROM News
      WHERE topic = cassandra

      -- Last N columns
      SELECT FIRST 10 REVERSED * FROM News
      WHERE topic = cassandra




Wednesday, March 28, 12
Counting

      -- Get your count on
      UPDATE inventory SET apples = apples + 1
          WHERE id = fruit;

      UPDATE inventory SET carrots = carrots - 1
          WHERE id = vegetable;




Wednesday, March 28, 12
Batching writes

      BEGIN BATCH
        INSERT INTO msgs (owner, subject, body)
            VALUES(jericevans, ‘Hi’, ‘Howdy’);
        UPDATE subjects SET subject = now
            WHERE owner = jericevans
      APPLY BATCH




Wednesday, March 28, 12
A query interface
                               should be...
                          Simple
                          Intuitive
                          Invisible
                          Performant(?)




Wednesday, March 28, 12
Drivers
                   •      Not a replacement for high-level, idiomatic
                          libraries
                   •      Avoids duplicating efforts, (error handling,
                          pooling, etc)
                   •      Consistently scoped, JDBC, etc
                   •      Consistently hosted, licensed
                   •      Discoverable
                   •      More work needed...


Wednesday, March 28, 12
Current lineup

                   • JDBC (Java)
                   • DB-API 2 (Python)
                   • PDO (PHP)
                   • Ruby
                   • Node.JS

Wednesday, March 28, 12
And what about interface
                                 stability?




Wednesday, March 28, 12
CQL 1.0

                   0.
                          8.
                               0




Wednesday, March 28, 12
CQL 2.0

                   0.              1.
                          8.            0.
                               0             0

                 • types made more consistent w/ SQL
                 • count() returns rows, not columns


Wednesday, March 28, 12
Wednesday, March 28, 12
CQL 3.0

                  0.            1.            1.
                       8.            0.            1.
                            0             0             0




Wednesday, March 28, 12
CQL 3.0
      -- A materialized timeline of tweets
      CREATE COLUMNFAMILY timeline (
          username text,
          posted_at timestamp,
          body text,
          posted_by text,
          PRIMARY KEY (username, posted_at)
      );




Wednesday, March 28, 12
CQL 3.0
    INSERT INTO timeline (username, posted_at, body, posted_by)
    VALUES (scotty, ‘2012-03-23 14:36’ ‘stupid klingons...’, jtkirk);

    INSERT INTO timeline (username, posted_at, body, posted_by)
    VALUES (scotty, ‘2012-03-23 16:12’ ‘@jtkirk green?’, spock);

    INSERT INTO timeline (username, posted_at, body, posted_by)
    VALUES (scotty, ‘2012-03-23 17:42’ ‘@spock yes, green’, jtkirk);

    INSERT INTO timeline (username, posted_at, body, posted_by)
    VALUES (scotty, ‘2012-03-25 08:14’ ‘get off my lawn!’, bones);




Wednesday, March 28, 12
In Cassandra’s eyes eye


                  (23/03 14:36, body): (23/03 14:36, posted_by): (23/03 16:12, body):
      scotty                                                                            ...
                    stupid klingons...           jtkirk            @jtkirk green?




Wednesday, March 28, 12
-- Tweets in Scotty’s timeline, by date
      SELECT * FROM timeline WHERE username =
          scotty AND posted_at > ‘2012-03-22’;




Wednesday, March 28, 12
Is it a row, or a table?
                                    Yes.
                username      posted_at           body           posted_by

                    scotty   23/03 14:36    stupid klingons...     jtkirk

                    scotty   23/03 16:12    @jtkirk green?         spock

                    scotty   23/03 17:42   @spock yes, green       jtkirk

                    scotty   25/03 08:14    get off my lawn!      bones



Wednesday, March 28, 12
Also...
                   • Column names are strictly UTF-8
                   • Column names are case-insensitive (unless
                          quoted)
                   • Old slice notation is gone (<start>..<end>)
                   • Static column families are actually static
                          (schema-enforced)


Wednesday, March 28, 12
$@#*!




                          NOT AGAIN!




Wednesday, March 28, 12
CQL 2.0 + 3.0 “beta”
                                                 You are
                                                  here




                   0.              1.             1.
                          8.            0.             1.
                               0             0              0




Wednesday, March 28, 12
Wednesday, March 28, 12
CQL 3.0
                                                          You will
                                                          be here




                0.            1.            1.             1.
                     8.            0.            1.             2.
                          0             0             0              0




Wednesday, March 28, 12
A query interface
                               should be...
                          Simple
                          Intuitive
                          Invisible
                          Performant(?)




Wednesday, March 28, 12
Performance
                              inserts




Wednesday, March 28, 12
Performance
                            inserts w/ index




Wednesday, March 28, 12
Performance
                           counter increments




Wednesday, March 28, 12
Performance
                              reads




Wednesday, March 28, 12
Wednesday, March 28, 12
A query interface
                               should be...
                          Simple
                          Intuitive
                          Invisible
                          Performant




Wednesday, March 28, 12
Help Wanted

                          • Writing tests
                          • Documentation
                          • Feedback
                          • Drivers

Wednesday, March 28, 12
Wednesday, March 28, 12

Contenu connexe

Similaire à Cassandra EU 2012 - CQL: Then, Now and When by Eric Evans

Use Your MySQL Knowledge to Become an Instant Cassandra Guru
Use Your MySQL Knowledge to Become an Instant Cassandra GuruUse Your MySQL Knowledge to Become an Instant Cassandra Guru
Use Your MySQL Knowledge to Become an Instant Cassandra GuruTim Callaghan
 
Conexao Java: Criando uma App Android
Conexao Java: Criando uma App AndroidConexao Java: Criando uma App Android
Conexao Java: Criando uma App AndroidErich Egert
 
The data model is dead, long live the data model
The data model is dead, long live the data modelThe data model is dead, long live the data model
The data model is dead, long live the data modelPatrick McFadin
 
Usability Testing: analyzing data
Usability Testing: analyzing dataUsability Testing: analyzing data
Usability Testing: analyzing dataKrista Kennedy
 
MySQL Cluster Scaling to a Billion Queries
MySQL Cluster Scaling to a Billion QueriesMySQL Cluster Scaling to a Billion Queries
MySQL Cluster Scaling to a Billion QueriesBernd Ocklin
 
Testing early mysql releases in a sandbox
Testing early mysql releases in a sandboxTesting early mysql releases in a sandbox
Testing early mysql releases in a sandboxGiuseppe Maxia
 
Apache Cassandra Opinion and Fact
Apache Cassandra Opinion and FactApache Cassandra Opinion and Fact
Apache Cassandra Opinion and Factmediumdata
 
Big Bad "Upgraded" Postgres
Big Bad "Upgraded" PostgresBig Bad "Upgraded" Postgres
Big Bad "Upgraded" PostgresRobert Treat
 
Supporting Agile Requirements Evolution via Paraconsistent Reasoning
Supporting Agile Requirements Evolution via Paraconsistent ReasoningSupporting Agile Requirements Evolution via Paraconsistent Reasoning
Supporting Agile Requirements Evolution via Paraconsistent ReasoningNeil Ernst
 
Structure Data 2014: INVERTING 80/20: BEYOND BESPOKE BIG DATA, Ari Gesher
Structure Data 2014: INVERTING 80/20: BEYOND BESPOKE BIG DATA, Ari GesherStructure Data 2014: INVERTING 80/20: BEYOND BESPOKE BIG DATA, Ari Gesher
Structure Data 2014: INVERTING 80/20: BEYOND BESPOKE BIG DATA, Ari GesherGigaom
 
What can we learn from NoSQL technologies?
What can we learn from NoSQL technologies?What can we learn from NoSQL technologies?
What can we learn from NoSQL technologies?Ivan Zoratti
 
The Rules of Scalable database
The Rules of Scalable databaseThe Rules of Scalable database
The Rules of Scalable databaseDahui Feng
 
The Future of Big Data is Relational (or why you can't escape SQL)
The Future of Big Data is Relational (or why you can't escape SQL)The Future of Big Data is Relational (or why you can't escape SQL)
The Future of Big Data is Relational (or why you can't escape SQL)OReillyStrata
 
Slide presentation pycassa_upload
Slide presentation pycassa_uploadSlide presentation pycassa_upload
Slide presentation pycassa_uploadRajini Ramesh
 
Java one2011 brisk-and_high_order_bits_from_cassandra_and_hadoop
Java one2011 brisk-and_high_order_bits_from_cassandra_and_hadoopJava one2011 brisk-and_high_order_bits_from_cassandra_and_hadoop
Java one2011 brisk-and_high_order_bits_from_cassandra_and_hadoopsrisatish ambati
 
When Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of TorqueboxWhen Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of Torqueboxrockyjaiswal
 
Cassandra EU 2012 - Data modelling workshop by Richard Low
Cassandra EU 2012 - Data modelling workshop by Richard LowCassandra EU 2012 - Data modelling workshop by Richard Low
Cassandra EU 2012 - Data modelling workshop by Richard LowAcunu
 

Similaire à Cassandra EU 2012 - CQL: Then, Now and When by Eric Evans (18)

Use Your MySQL Knowledge to Become an Instant Cassandra Guru
Use Your MySQL Knowledge to Become an Instant Cassandra GuruUse Your MySQL Knowledge to Become an Instant Cassandra Guru
Use Your MySQL Knowledge to Become an Instant Cassandra Guru
 
Conexao Java: Criando uma App Android
Conexao Java: Criando uma App AndroidConexao Java: Criando uma App Android
Conexao Java: Criando uma App Android
 
The data model is dead, long live the data model
The data model is dead, long live the data modelThe data model is dead, long live the data model
The data model is dead, long live the data model
 
Usability Testing: analyzing data
Usability Testing: analyzing dataUsability Testing: analyzing data
Usability Testing: analyzing data
 
MySQL Cluster Scaling to a Billion Queries
MySQL Cluster Scaling to a Billion QueriesMySQL Cluster Scaling to a Billion Queries
MySQL Cluster Scaling to a Billion Queries
 
Testing early mysql releases in a sandbox
Testing early mysql releases in a sandboxTesting early mysql releases in a sandbox
Testing early mysql releases in a sandbox
 
Apache Cassandra Opinion and Fact
Apache Cassandra Opinion and FactApache Cassandra Opinion and Fact
Apache Cassandra Opinion and Fact
 
Big Bad "Upgraded" Postgres
Big Bad "Upgraded" PostgresBig Bad "Upgraded" Postgres
Big Bad "Upgraded" Postgres
 
Supporting Agile Requirements Evolution via Paraconsistent Reasoning
Supporting Agile Requirements Evolution via Paraconsistent ReasoningSupporting Agile Requirements Evolution via Paraconsistent Reasoning
Supporting Agile Requirements Evolution via Paraconsistent Reasoning
 
Structure Data 2014: INVERTING 80/20: BEYOND BESPOKE BIG DATA, Ari Gesher
Structure Data 2014: INVERTING 80/20: BEYOND BESPOKE BIG DATA, Ari GesherStructure Data 2014: INVERTING 80/20: BEYOND BESPOKE BIG DATA, Ari Gesher
Structure Data 2014: INVERTING 80/20: BEYOND BESPOKE BIG DATA, Ari Gesher
 
What can we learn from NoSQL technologies?
What can we learn from NoSQL technologies?What can we learn from NoSQL technologies?
What can we learn from NoSQL technologies?
 
Rest in flask
Rest in flaskRest in flask
Rest in flask
 
The Rules of Scalable database
The Rules of Scalable databaseThe Rules of Scalable database
The Rules of Scalable database
 
The Future of Big Data is Relational (or why you can't escape SQL)
The Future of Big Data is Relational (or why you can't escape SQL)The Future of Big Data is Relational (or why you can't escape SQL)
The Future of Big Data is Relational (or why you can't escape SQL)
 
Slide presentation pycassa_upload
Slide presentation pycassa_uploadSlide presentation pycassa_upload
Slide presentation pycassa_upload
 
Java one2011 brisk-and_high_order_bits_from_cassandra_and_hadoop
Java one2011 brisk-and_high_order_bits_from_cassandra_and_hadoopJava one2011 brisk-and_high_order_bits_from_cassandra_and_hadoop
Java one2011 brisk-and_high_order_bits_from_cassandra_and_hadoop
 
When Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of TorqueboxWhen Ruby Meets Java - The Power of Torquebox
When Ruby Meets Java - The Power of Torquebox
 
Cassandra EU 2012 - Data modelling workshop by Richard Low
Cassandra EU 2012 - Data modelling workshop by Richard LowCassandra EU 2012 - Data modelling workshop by Richard Low
Cassandra EU 2012 - Data modelling workshop by Richard Low
 

Plus de Acunu

Acunu and Hailo: a realtime analytics case study on Cassandra
Acunu and Hailo: a realtime analytics case study on CassandraAcunu and Hailo: a realtime analytics case study on Cassandra
Acunu and Hailo: a realtime analytics case study on CassandraAcunu
 
Virtual nodes: Operational Aspirin
Virtual nodes: Operational AspirinVirtual nodes: Operational Aspirin
Virtual nodes: Operational AspirinAcunu
 
Acunu Analytics and Cassandra at Hailo All Your Base 2013
Acunu Analytics and Cassandra at Hailo All Your Base 2013 Acunu Analytics and Cassandra at Hailo All Your Base 2013
Acunu Analytics and Cassandra at Hailo All Your Base 2013 Acunu
 
Understanding Cassandra internals to solve real-world problems
Understanding Cassandra internals to solve real-world problemsUnderstanding Cassandra internals to solve real-world problems
Understanding Cassandra internals to solve real-world problemsAcunu
 
Acunu Analytics: Simpler Real-Time Cassandra Apps
Acunu Analytics: Simpler Real-Time Cassandra AppsAcunu Analytics: Simpler Real-Time Cassandra Apps
Acunu Analytics: Simpler Real-Time Cassandra AppsAcunu
 
All Your Base
All Your BaseAll Your Base
All Your BaseAcunu
 
Realtime Analytics with Apache Cassandra
Realtime Analytics with Apache CassandraRealtime Analytics with Apache Cassandra
Realtime Analytics with Apache CassandraAcunu
 
Realtime Analytics with Apache Cassandra - JAX London
Realtime Analytics with Apache Cassandra - JAX LondonRealtime Analytics with Apache Cassandra - JAX London
Realtime Analytics with Apache Cassandra - JAX LondonAcunu
 
Real-time Cassandra
Real-time CassandraReal-time Cassandra
Real-time CassandraAcunu
 
Realtime Analytics on the Twitter Firehose with Apache Cassandra - Denormaliz...
Realtime Analytics on the Twitter Firehose with Apache Cassandra - Denormaliz...Realtime Analytics on the Twitter Firehose with Apache Cassandra - Denormaliz...
Realtime Analytics on the Twitter Firehose with Apache Cassandra - Denormaliz...Acunu
 
Realtime Analytics with Cassandra
Realtime Analytics with CassandraRealtime Analytics with Cassandra
Realtime Analytics with CassandraAcunu
 
Acunu Analytics @ Cassandra London
Acunu Analytics @ Cassandra LondonAcunu Analytics @ Cassandra London
Acunu Analytics @ Cassandra LondonAcunu
 
Exploring Big Data value for your business
Exploring Big Data value for your businessExploring Big Data value for your business
Exploring Big Data value for your businessAcunu
 
Realtime Analytics on the Twitter Firehose with Cassandra
Realtime Analytics on the Twitter Firehose with CassandraRealtime Analytics on the Twitter Firehose with Cassandra
Realtime Analytics on the Twitter Firehose with CassandraAcunu
 
Progressive NOSQL: Cassandra
Progressive NOSQL: CassandraProgressive NOSQL: Cassandra
Progressive NOSQL: CassandraAcunu
 
Cassandra EU 2012 - Overview of Case Studies and State of the Market by 451 R...
Cassandra EU 2012 - Overview of Case Studies and State of the Market by 451 R...Cassandra EU 2012 - Overview of Case Studies and State of the Market by 451 R...
Cassandra EU 2012 - Overview of Case Studies and State of the Market by 451 R...Acunu
 
Cassandra EU 2012 - Putting the X Factor into Cassandra
Cassandra EU 2012 - Putting the X Factor into CassandraCassandra EU 2012 - Putting the X Factor into Cassandra
Cassandra EU 2012 - Putting the X Factor into CassandraAcunu
 
Cassandra EU 2012 - Netflix's Cassandra Architecture and Open Source Efforts
Cassandra EU 2012 - Netflix's Cassandra Architecture and Open Source EffortsCassandra EU 2012 - Netflix's Cassandra Architecture and Open Source Efforts
Cassandra EU 2012 - Netflix's Cassandra Architecture and Open Source EffortsAcunu
 
Next Generation Cassandra
Next Generation CassandraNext Generation Cassandra
Next Generation CassandraAcunu
 
Cassandra EU 2012 - Storage Internals by Nicolas Favre-Felix
Cassandra EU 2012 - Storage Internals by Nicolas Favre-FelixCassandra EU 2012 - Storage Internals by Nicolas Favre-Felix
Cassandra EU 2012 - Storage Internals by Nicolas Favre-FelixAcunu
 

Plus de Acunu (20)

Acunu and Hailo: a realtime analytics case study on Cassandra
Acunu and Hailo: a realtime analytics case study on CassandraAcunu and Hailo: a realtime analytics case study on Cassandra
Acunu and Hailo: a realtime analytics case study on Cassandra
 
Virtual nodes: Operational Aspirin
Virtual nodes: Operational AspirinVirtual nodes: Operational Aspirin
Virtual nodes: Operational Aspirin
 
Acunu Analytics and Cassandra at Hailo All Your Base 2013
Acunu Analytics and Cassandra at Hailo All Your Base 2013 Acunu Analytics and Cassandra at Hailo All Your Base 2013
Acunu Analytics and Cassandra at Hailo All Your Base 2013
 
Understanding Cassandra internals to solve real-world problems
Understanding Cassandra internals to solve real-world problemsUnderstanding Cassandra internals to solve real-world problems
Understanding Cassandra internals to solve real-world problems
 
Acunu Analytics: Simpler Real-Time Cassandra Apps
Acunu Analytics: Simpler Real-Time Cassandra AppsAcunu Analytics: Simpler Real-Time Cassandra Apps
Acunu Analytics: Simpler Real-Time Cassandra Apps
 
All Your Base
All Your BaseAll Your Base
All Your Base
 
Realtime Analytics with Apache Cassandra
Realtime Analytics with Apache CassandraRealtime Analytics with Apache Cassandra
Realtime Analytics with Apache Cassandra
 
Realtime Analytics with Apache Cassandra - JAX London
Realtime Analytics with Apache Cassandra - JAX LondonRealtime Analytics with Apache Cassandra - JAX London
Realtime Analytics with Apache Cassandra - JAX London
 
Real-time Cassandra
Real-time CassandraReal-time Cassandra
Real-time Cassandra
 
Realtime Analytics on the Twitter Firehose with Apache Cassandra - Denormaliz...
Realtime Analytics on the Twitter Firehose with Apache Cassandra - Denormaliz...Realtime Analytics on the Twitter Firehose with Apache Cassandra - Denormaliz...
Realtime Analytics on the Twitter Firehose with Apache Cassandra - Denormaliz...
 
Realtime Analytics with Cassandra
Realtime Analytics with CassandraRealtime Analytics with Cassandra
Realtime Analytics with Cassandra
 
Acunu Analytics @ Cassandra London
Acunu Analytics @ Cassandra LondonAcunu Analytics @ Cassandra London
Acunu Analytics @ Cassandra London
 
Exploring Big Data value for your business
Exploring Big Data value for your businessExploring Big Data value for your business
Exploring Big Data value for your business
 
Realtime Analytics on the Twitter Firehose with Cassandra
Realtime Analytics on the Twitter Firehose with CassandraRealtime Analytics on the Twitter Firehose with Cassandra
Realtime Analytics on the Twitter Firehose with Cassandra
 
Progressive NOSQL: Cassandra
Progressive NOSQL: CassandraProgressive NOSQL: Cassandra
Progressive NOSQL: Cassandra
 
Cassandra EU 2012 - Overview of Case Studies and State of the Market by 451 R...
Cassandra EU 2012 - Overview of Case Studies and State of the Market by 451 R...Cassandra EU 2012 - Overview of Case Studies and State of the Market by 451 R...
Cassandra EU 2012 - Overview of Case Studies and State of the Market by 451 R...
 
Cassandra EU 2012 - Putting the X Factor into Cassandra
Cassandra EU 2012 - Putting the X Factor into CassandraCassandra EU 2012 - Putting the X Factor into Cassandra
Cassandra EU 2012 - Putting the X Factor into Cassandra
 
Cassandra EU 2012 - Netflix's Cassandra Architecture and Open Source Efforts
Cassandra EU 2012 - Netflix's Cassandra Architecture and Open Source EffortsCassandra EU 2012 - Netflix's Cassandra Architecture and Open Source Efforts
Cassandra EU 2012 - Netflix's Cassandra Architecture and Open Source Efforts
 
Next Generation Cassandra
Next Generation CassandraNext Generation Cassandra
Next Generation Cassandra
 
Cassandra EU 2012 - Storage Internals by Nicolas Favre-Felix
Cassandra EU 2012 - Storage Internals by Nicolas Favre-FelixCassandra EU 2012 - Storage Internals by Nicolas Favre-Felix
Cassandra EU 2012 - Storage Internals by Nicolas Favre-Felix
 

Dernier

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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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
 
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
 
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
 
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
 

Dernier (20)

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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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...
 
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
 
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
 
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
 
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
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
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
 
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
 
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
 

Cassandra EU 2012 - CQL: Then, Now and When by Eric Evans

  • 1. CQL: Then, Now, and When Eric Evans eric@acunu.com Cassandra Europe March 28, 2012 Wednesday, March 28, 12
  • 2. Cassandra Query Language (aka CQL) • Query language for Apache Cassandra • SQL for the most part • An alternative query interface • Available since Cassandra 0.8.0 Wednesday, March 28, 12
  • 6. Not a troll at all, actually. Wednesday, March 28, 12
  • 7. Status Quo • RPC-based query interface • Low level; very little abstraction • Implemented in Thrift • Compact binary serialization • Loads of supported languages • Generated language code Wednesday, March 28, 12
  • 8. Unstable $@#*! Relax NOT AGAIN! It’ll take you 5 minutes to update your code. Wednesday, March 28, 12
  • 10. This cannot be unseen! // Your column Column col = new Column(ByteBuffer.wrap(“name”.getBytes())); col.setValue(ByteBuffer.wrap(“value”.getBytes())); col.setTimestamp(System.currentTimeMillis()); // Don’t ask ColumnOrSuperColumn cosc = new ColumnOrSuperColumn(); cosc.setColumn(cosc); // Hang on, here we go... Mutation mutation = new Mutation(); mutation.setColumnOrSuperColumn(cosc); List<Mutation> mutations = new ArrayList<Mutation>(); mutations.add(mutation); Map mutations_map = new HashMap<ByteBuffer, Map<String, List<Mutation>>>(); Map cf_map = new Map<String, List<Mutation>>(); cf_map.set(“Standard1”, mutations); mutations_map.put(ByteBuffer.wrap(“key”.getBytes()), cf_map); cassandra.batch_mutate(mutations_map, consistency_level); Wednesday, March 28, 12
  • 11. This cannot be unseen! // Your column Column col = new Column(ByteBuffer.wrap(“name”.getBytes())); col.setValue(ByteBuffer.wrap(“value”.getBytes())); col.setTimestamp(System.currentTimeMillis()); // Don’t ask ColumnOrSuperColumn cosc = new ColumnOrSuperColumn(); cosc.setColumn(cosc); // Hang on, here we go... Mutation mutation = new Mutation(); mutation.setColumnOrSuperColumn(cosc); List<Mutation> mutations = new ArrayList<Mutation>(); mutations.add(mutation); Map mutations_map = new HashMap<ByteBuffer, Map<String, List<Mutation>>>(); Map cf_map = new Map<String, List<Mutation>>(); cf_map.set(“Standard1”, mutations); mutations_map.put(ByteBuffer.wrap(“key”.getBytes()), cf_map); cassandra.batch_mutate(mutations_map, consistency_level); Wednesday, March 28, 12
  • 12. A query interface should be... Simple Intuitive Invisible Performant(?) Wednesday, March 28, 12
  • 13. Alternatives • REST • RPC (Thrift, Avro, Protobuf, etc) • SQL (bahahaha) • etc, etc Wednesday, March 28, 12
  • 14. REST Pros Cons • Ubiquitous • Fails expectations • Frequently requested • Slow • Client uniformity Wednesday, March 28, 12
  • 15. RPC Pros Cons • Easy to implement • Poor mental fit • Performant • Heavy dependency Wednesday, March 28, 12
  • 16. SQL Pros Cons • Ubiquitous • People whinging • Widely known • Security(?) • Excellent mental fit • Client uniformity Wednesday, March 28, 12
  • 17. SQL Pros Cons • Ubiquitous • People whinging • Widely known • Security(?) • Excellent mental fit • Client uniformity Wednesday, March 28, 12
  • 19. Hello... -- Create or update INSERT INTO users (id, given, surname) VALUES (jericevans, Eric, Evans); -- Create or update UPDATE users SET given = Eric, surname = Evans WHERE id = jericevans; SELECT surname, given FROM users WHERE id = jericevans; Wednesday, March 28, 12
  • 20. ...is it me you’re looking for? -- Adding an index CREATE INDEX surnameidx ON users (surname); SELECT id, given FROM users WHERE surname = Evans; -- Limiting the number of rows SELECT id, given FROM users WHERE surname = Evans LIMIT 1000; Wednesday, March 28, 12
  • 21. Querying column ranges -- From column, to column SELECT ‘2012-01-01’..’2012-03-28’ FROM News WHERE topic = cassandra -- Last N columns SELECT FIRST 10 REVERSED * FROM News WHERE topic = cassandra Wednesday, March 28, 12
  • 22. Counting -- Get your count on UPDATE inventory SET apples = apples + 1 WHERE id = fruit; UPDATE inventory SET carrots = carrots - 1 WHERE id = vegetable; Wednesday, March 28, 12
  • 23. Batching writes BEGIN BATCH INSERT INTO msgs (owner, subject, body) VALUES(jericevans, ‘Hi’, ‘Howdy’); UPDATE subjects SET subject = now WHERE owner = jericevans APPLY BATCH Wednesday, March 28, 12
  • 24. A query interface should be... Simple Intuitive Invisible Performant(?) Wednesday, March 28, 12
  • 25. Drivers • Not a replacement for high-level, idiomatic libraries • Avoids duplicating efforts, (error handling, pooling, etc) • Consistently scoped, JDBC, etc • Consistently hosted, licensed • Discoverable • More work needed... Wednesday, March 28, 12
  • 26. Current lineup • JDBC (Java) • DB-API 2 (Python) • PDO (PHP) • Ruby • Node.JS Wednesday, March 28, 12
  • 27. And what about interface stability? Wednesday, March 28, 12
  • 28. CQL 1.0 0. 8. 0 Wednesday, March 28, 12
  • 29. CQL 2.0 0. 1. 8. 0. 0 0 • types made more consistent w/ SQL • count() returns rows, not columns Wednesday, March 28, 12
  • 31. CQL 3.0 0. 1. 1. 8. 0. 1. 0 0 0 Wednesday, March 28, 12
  • 32. CQL 3.0 -- A materialized timeline of tweets CREATE COLUMNFAMILY timeline ( username text, posted_at timestamp, body text, posted_by text, PRIMARY KEY (username, posted_at) ); Wednesday, March 28, 12
  • 33. CQL 3.0 INSERT INTO timeline (username, posted_at, body, posted_by) VALUES (scotty, ‘2012-03-23 14:36’ ‘stupid klingons...’, jtkirk); INSERT INTO timeline (username, posted_at, body, posted_by) VALUES (scotty, ‘2012-03-23 16:12’ ‘@jtkirk green?’, spock); INSERT INTO timeline (username, posted_at, body, posted_by) VALUES (scotty, ‘2012-03-23 17:42’ ‘@spock yes, green’, jtkirk); INSERT INTO timeline (username, posted_at, body, posted_by) VALUES (scotty, ‘2012-03-25 08:14’ ‘get off my lawn!’, bones); Wednesday, March 28, 12
  • 34. In Cassandra’s eyes eye (23/03 14:36, body): (23/03 14:36, posted_by): (23/03 16:12, body): scotty ... stupid klingons... jtkirk @jtkirk green? Wednesday, March 28, 12
  • 35. -- Tweets in Scotty’s timeline, by date SELECT * FROM timeline WHERE username = scotty AND posted_at > ‘2012-03-22’; Wednesday, March 28, 12
  • 36. Is it a row, or a table? Yes. username posted_at body posted_by scotty 23/03 14:36 stupid klingons... jtkirk scotty 23/03 16:12 @jtkirk green? spock scotty 23/03 17:42 @spock yes, green jtkirk scotty 25/03 08:14 get off my lawn! bones Wednesday, March 28, 12
  • 37. Also... • Column names are strictly UTF-8 • Column names are case-insensitive (unless quoted) • Old slice notation is gone (<start>..<end>) • Static column families are actually static (schema-enforced) Wednesday, March 28, 12
  • 38. $@#*! NOT AGAIN! Wednesday, March 28, 12
  • 39. CQL 2.0 + 3.0 “beta” You are here 0. 1. 1. 8. 0. 1. 0 0 0 Wednesday, March 28, 12
  • 41. CQL 3.0 You will be here 0. 1. 1. 1. 8. 0. 1. 2. 0 0 0 0 Wednesday, March 28, 12
  • 42. A query interface should be... Simple Intuitive Invisible Performant(?) Wednesday, March 28, 12
  • 43. Performance inserts Wednesday, March 28, 12
  • 44. Performance inserts w/ index Wednesday, March 28, 12
  • 45. Performance counter increments Wednesday, March 28, 12
  • 46. Performance reads Wednesday, March 28, 12
  • 48. A query interface should be... Simple Intuitive Invisible Performant Wednesday, March 28, 12
  • 49. Help Wanted • Writing tests • Documentation • Feedback • Drivers Wednesday, March 28, 12