Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences betweeen Hector Cassandra and JDBC

I'm currently starting a project that use Cassandra Apache. So I'm interesting in accessing to my database cassandra from Java. For that, I'm using Hector Cassandra. However, I've some doubts about what's the differences between the access via Hector or JDBC Cassandra (specifically this: https://code.google.com/a/apache-extras.org/p/cassandra-jdbc/).

I believe the following (although I not sure if I'm right):

  • one difference between both could be that are API of different level (I consider that Hector Cassandra is an API of higher-level than JDBC Cassandra)?

  • in JDBC Cassandra is used CQL for accessing/modifying the database, while Hector Cassandra don't use CQL (only use the methods provided for that).

I'll be thankful if someone can help me and tell me if I'm right/wrong in the previous lines and more differences between both (Hector and JDBC Cassandra).

Thank in advance!

like image 393
mol Avatar asked Sep 03 '13 18:09

mol


People also ask

What is Hector in Cassandra?

Hector is a high-level client API for Apache Cassandra. Named after Hector, a warrior of Troy in Greek mythology, it is a substitute for the Cassandra Java Client, or Thrift, that is encapsulated by Hector. It also has Maven repository access.

Does Cassandra use JDBC?

The Cassandra JDBC Driver enables users to connect with live Cassandra data, directly from any applications that support JDBC connectivity. Connect Java applications with the Cassandra real-time NoSQL cloud database service.


2 Answers

Official Cassandra Java Driver (https://github.com/datastax/java-driver) is probably the best (IMHO, the only) choice for a new project for several reasons:

New features

All other Cassandra clients (Hector, Astyanax, etc) are based on legacy Thrift RPC protocol. RPC "One response per one request" model has severe limitations, for example it doesn't allow processing several requests at the same time in a single connection or streaming large ResultSets.

So, DataStax developed a new protocol that doesn't have RPC limitations. Thrift API won't be getting new features, it's only kept for backward-compatibility. In contrast, Java Driver is actively developed to incorporate the new features of Cassandra 2.0, like conditional updates, batching prepared statements, etc. The overview of new features is here: http://www.datastax.com/dev/blog/cql-in-cassandra-2-0

Convenience

In early Cassandra days (0.7) in our company we have used in-house low-level Thrift client. Later on we have used Hector, Pelops and Astyanax in various projects. I can say that the clients based on Java Driver look the most simple and clean to me.

Performance

We have made some performance testing of Cassandra Java Driver vs other clients. In most scenarios the performance is roughly the same. However, there are certain situations when Cassandra Java Driver significantly outperforms other clients due to its asynchronous nature.

Btw, there's a couple of related questions with excellent answers:

  • Advantages of using cql over thrift
  • Cassandra Client Java API's

EDIT: When I wrote this, I wasn't aware that Achilles (https://github.com/doanduyhai/Achilles) mentioned in another answer has CQL implementation that works via Java Driver. For the same of completeness I must say that Achilles' DAO on top of CQL might be (or might became one day) viable alternative to plain CQL via Java Driver.

like image 180
Wildfire Avatar answered Oct 02 '22 16:10

Wildfire


@mol

Why do you restrict to Hector and cassandra-jdbc if you're starting a new project ?

There are many other interesting choices:

  • Astyanax as Martin mentioned (Thrift & CQL3)
  • FireBrand (Thrift via Hector)
  • Achilles I've just developed (CQL3 & Cassandra 2.0 via Java driver core)
  • Java Driver Core for plain CQL3
like image 29
doanduyhai Avatar answered Oct 02 '22 17:10

doanduyhai