سؤال

I am working in a Java web application, using NoSQL (target is Cassandra). I use Astyanax as Cassandra client since it is suggested the best client of Cassandra for now. I've just approached Cassandra for 2 weeks, so many things is so weird to me.
During my working, I encountered some problems and I do not know how to overcome:

  1. Is table created from CQL like column family created by Thrift API? I feel they are similar, but maybe there are some differences behind. For example:

    • table create by CQL command cannot be accessed by Thrift API
    • Thrift-based APIs cannot work with tables created by CQL, but CQL methods can access column family created by Thrift API!
  2. ​Is primary key in table correspond to row key in column family?

  3. In CQL I can declare a table which contains a collection/set/map inside. Can I do the same thing in Thrift API?
  4. If my application needs both of them (column families and tables), how can they deal with each other?
  5. I recognize one thing: I cannot use Thrift API to do manipulating data on tables create by CQL, and vice versa. I wonder that that, how can I remember which table/column family created from which way so that I can use the correct APIs to process data? For the time being, we don't have a general way to handle two of them, do we? AFAIK, Thrift API and CQL do not have a same interface, so they cannot understand each other?!

Could you please help me explain these things? Thank you so much.

هل كانت مفيدة؟

المحلول

  1. Yes. It's impossible to update the Thrift APIs to be CQL-aware without breaking existing applications. So if you use CQL you are committing to using CQL clients only like the Java driver, and not Astyanax, Hector, et al. But this is no great sacrifice since CQL is much more usable.

  2. For a simple PK (i.e., single column), yes. For a compound PK, it's a bit more complicated.

  3. No. The Thrift API operates at a lower level, by design. (So you'd see the individual storage cells that make up the Map, for instance.)

  4. I don't understand the question. With CQL you can do everything you could do with Thrift, but more easily.

  5. Simple; don't mix the two. Stick with one or the other.

نصائح أخرى

In my opinion, I believe focus is shifting towards making cassandra look like a RDBMS with SQL Queries to gain wider adoption. But with inconsistencies between work done using Hector/Astyanax(thrift) and CQL, i think it will hurt adoption. Its almost a U turn from hector/astyanax to CQL in the middle of the journey.

Atleast CQL should have been planned in such a way that Thrift api (and high level java apis on top of it) have no problem in transitioning.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top