Not just NoSQL, It’s MoSQL
        Cassandra SF
        July 11, 2011
              Eric Evans
      eevans@rackspace.com
             @jericevans
      http://blog.sym-link.com
Cassandra Query Language
●   Structured query language for Apache
    Cassandra.
●   CQL for short (pronounced /siːkw əl/).
●   SQL alike (best effort).
●   An alternative to the existing API, not a
    replacement (not yet).
●   Available for use in Cassandra 0.8.0.
Wait, aren't you the guy...?
So, is this a troll?
Problem?
Naw.
(not a troll, honest)
But, why?
Because the API sucks.
“Thrift sucks, ergo the API sucks”
●   Generated code (C++ compiler).
●   Loads of languages, but varying levels of
    support.
    ●   PHP anyone?
●   Upstream alternating between extremes of
    combativeness and apathy.
    ●   Patches ignored, (or refused).
    ●   Loads of (serious )bugs ignored for long periods.
    ●   Infrequent releases.
“Avro Does Not Suck, so...”
1. Avro
2. Something, something, something
3. Profit!
And the API still sucks.
Brass Tacks
●   Unstable
    ●   Too tightly coupled to internal APIs
●   Too difficult to use
    ●   Not enough abstraction (and passing the buck to
        3rd-party API maintainers is weak)
    ●   Poor mental fit for query/data models
Back to the drawing board
●   RPC (Thrift, Avro, Protobuf, etc)
●   REST
●   Query language
●   Etc, etc
Back to the drawing board
●   RPC (Thrift, Avro, Protobuf, etc)
    ●   Easy to implement
    ●   Performant
●   REST
●   Query language
●   Etc, etc
Back to the drawing board
●   RPC (Thrift, Avro, Protobuf, etc)
    ●   Easy to implement
    ●   Performant
●   REST
    ●   Little need for client abstraction
●   Query language
●   Etc, etc
Back to the drawing board
●   RPC (Thrift, Avro, Protobuf, etc)
    ●   Easy to implement
    ●   Performant
●   REST
    ●   Little need for client abstraction
●   Query language
    ●   Little need for client abstraction!
    ●   Reads well; What you see is what you get
    ●   The Devil we all know
●   Etc, etc
Grok This
firstname = Column(name="firstname", value="Eric", timestamp=time)
firstcosc = ColumnOrSuperColumn(column=firstname)
lastname = Column(name="lastname", value="Evans", timestamp=time)
lastcosc = ColumnOrSuperColumn(column=lastname)


mutations = []
mutations.append(Mutation(column_or_supercolumn=firstcosc))
mutations.append(Mutation(column_or_supercolumn=lastcosc))


client.batch_mutate(mutation_map={"eevans": {"table": mutations}},
                   consistency_level=ConsistencyLevel.ONE)
What about this?



UPDATE table
SET firstname=Eric, lastname=Evans
WHERE KEY=eevans
Grok This

parent = ColumnParent(column_family="table")
colnames = ["firstname", "lastname"]
predicate = SlicePredicate(column_names=colnames)
row = client.get_slice(key="eevans",
                       column_parent=parent,
                       predicate=predicate,
                       consistency_level=CL.ONE)
And this?



SELECT firstname, lastname
FROM table
WHERE KEY = eevans
Lessons Learned
●   Know when to take a step back
●   Listen to your users; Read between the lines
●   Beware quick/easy consensus
●   Just because it's old doesn't mean it's bad
●   Just because it's the brunt of jokes, doesn't
    make it wrong (works for Thrift and SQL)
Language
●   Versioned specification (http://semver.og)
    ●   Major – Breaking changes, (rare to never)
    ●   Minor – Backward compatible changes
    ●   Patch – Bug fixes
Drivers
●   Maintained and distributed by us
●   Separate development cycles; Separately
    versioned
●   Support a language version, not a Cassandra
    version!
●   Minimal, low-level (not the place for an ORM)
●   Idiomatic
●   client-dev@cassandra.apache.org
More Info
●   Docs (doc/cql/CQL.html)
●   http://www.datastax.com/docs/0.8/api/using_cql
●   http://caqel.deadcafe.org (live demo!)
●   cqlsh (interactive shell shipped w/ Python
    driver)
Cassandra: Not Just NoSQL, It's MoSQL

Cassandra: Not Just NoSQL, It's MoSQL

  • 1.
    Not just NoSQL,It’s MoSQL Cassandra SF July 11, 2011 Eric Evans eevans@rackspace.com @jericevans http://blog.sym-link.com
  • 2.
    Cassandra Query Language ● Structured query language for Apache Cassandra. ● CQL for short (pronounced /siːkw əl/). ● SQL alike (best effort). ● An alternative to the existing API, not a replacement (not yet). ● Available for use in Cassandra 0.8.0.
  • 3.
    Wait, aren't youthe guy...?
  • 5.
    So, is thisa troll?
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
    “Thrift sucks, ergothe API sucks” ● Generated code (C++ compiler). ● Loads of languages, but varying levels of support. ● PHP anyone? ● Upstream alternating between extremes of combativeness and apathy. ● Patches ignored, (or refused). ● Loads of (serious )bugs ignored for long periods. ● Infrequent releases.
  • 11.
    “Avro Does NotSuck, so...” 1. Avro 2. Something, something, something 3. Profit!
  • 12.
    And the APIstill sucks.
  • 13.
    Brass Tacks ● Unstable ● Too tightly coupled to internal APIs ● Too difficult to use ● Not enough abstraction (and passing the buck to 3rd-party API maintainers is weak) ● Poor mental fit for query/data models
  • 14.
    Back to thedrawing board ● RPC (Thrift, Avro, Protobuf, etc) ● REST ● Query language ● Etc, etc
  • 15.
    Back to thedrawing board ● RPC (Thrift, Avro, Protobuf, etc) ● Easy to implement ● Performant ● REST ● Query language ● Etc, etc
  • 16.
    Back to thedrawing board ● RPC (Thrift, Avro, Protobuf, etc) ● Easy to implement ● Performant ● REST ● Little need for client abstraction ● Query language ● Etc, etc
  • 17.
    Back to thedrawing board ● RPC (Thrift, Avro, Protobuf, etc) ● Easy to implement ● Performant ● REST ● Little need for client abstraction ● Query language ● Little need for client abstraction! ● Reads well; What you see is what you get ● The Devil we all know ● Etc, etc
  • 18.
    Grok This firstname =Column(name="firstname", value="Eric", timestamp=time) firstcosc = ColumnOrSuperColumn(column=firstname) lastname = Column(name="lastname", value="Evans", timestamp=time) lastcosc = ColumnOrSuperColumn(column=lastname) mutations = [] mutations.append(Mutation(column_or_supercolumn=firstcosc)) mutations.append(Mutation(column_or_supercolumn=lastcosc)) client.batch_mutate(mutation_map={"eevans": {"table": mutations}}, consistency_level=ConsistencyLevel.ONE)
  • 19.
    What about this? UPDATEtable SET firstname=Eric, lastname=Evans WHERE KEY=eevans
  • 20.
    Grok This parent =ColumnParent(column_family="table") colnames = ["firstname", "lastname"] predicate = SlicePredicate(column_names=colnames) row = client.get_slice(key="eevans", column_parent=parent, predicate=predicate, consistency_level=CL.ONE)
  • 21.
    And this? SELECT firstname,lastname FROM table WHERE KEY = eevans
  • 22.
    Lessons Learned ● Know when to take a step back ● Listen to your users; Read between the lines ● Beware quick/easy consensus ● Just because it's old doesn't mean it's bad ● Just because it's the brunt of jokes, doesn't make it wrong (works for Thrift and SQL)
  • 23.
    Language ● Versioned specification (http://semver.og) ● Major – Breaking changes, (rare to never) ● Minor – Backward compatible changes ● Patch – Bug fixes
  • 24.
    Drivers ● Maintained and distributed by us ● Separate development cycles; Separately versioned ● Support a language version, not a Cassandra version! ● Minimal, low-level (not the place for an ORM) ● Idiomatic ● client-dev@cassandra.apache.org
  • 25.
    More Info ● Docs (doc/cql/CQL.html) ● http://www.datastax.com/docs/0.8/api/using_cql ● http://caqel.deadcafe.org (live demo!) ● cqlsh (interactive shell shipped w/ Python driver)