Differences betweeen Hector Cassandra and JDBC
Asked Answered
G

4

5

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!

Goldshlag answered 3/9, 2013 at 18:4 Comment(0)
C
11

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:

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.

Criswell answered 4/9, 2013 at 11:17 Comment(0)
P
4

@mol

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

There are many other interesting choices:

Petasus answered 3/9, 2013 at 19:44 Comment(2)
I'm sorry, I haven't explained fine. I'm colaborating in a project that other people already started a few years ago. I have to continue it since the current state of the project. Then, how it's developed using Hector Cassandra I've to continue using this technology. So, the problem is that by other hand this project use a JDBC for accessing to Cassandra instead of accessing using Hector Cassandra. Then, it's my doubts, what must each technology (Hector or JDBC for Cassandra) be used for?Goldshlag
Wow! I wasn't aware that Achilles now works via Java Driver. I'll update my answer :)Criswell
E
2

Hector is indeed a higher-level API. Internally it will use Cassandra's Thrift API to execute its functions. It will not convert them to equivalent CQL calls. But its API also provides access to CQL. In this case it will pass the CQL (via Thrift) to Cassandra's APIs for CQL.

CQL in Cassandra is a SQL-like language that works via the Cassandra APIs. So it does not provide any additional capability in the use of Cassandra than the APIs but does make it easier at times to use. If you are considering using Hector I would also look at Astyanax which is a newer take on a high-level Java API to Cassandra.

Emilia answered 3/9, 2013 at 18:13 Comment(3)
Thanks for your answer. When I say that Hector not use CQL, I refer that it's not used for Hector of the same way that it's used for JDBC. In JDBC you have to do: stIntruction.executeUpdate("CREATE COLUMNFAMILY ...."); for accessing to the db. However in Hector you call a function that executes CQL code internally. am I right?Goldshlag
I can only use JDBC Cassandra (concretely this: code.google.com/a/apache-extras.org/p/cassandra-jdbc) or Hector Cassandra. Anyway I'll take it into account for future projects. Thanks!Goldshlag
@Goldshlag i edited the answer to try to clarify. if this answers your question please accept it and upvote the answer. that is the stackoverflow way.Emilia
G
1

Since you are starting a new project, it is best to start with CQL as Java native driver:

http://www.datastax.com/documentation/developer/java-driver/1.0/webhelp/index.html#common/drivers/introduction/introArchOverview_c.html

Per DataStax, it is 10-15% faster than Thrift APIs, as it uses Binary Protocol.

Gitlow answered 4/9, 2013 at 12:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.