New Cassandra project - Astyanax or Java Driver?
Asked Answered
H

5

16

I'm starting a new project with Cassandra (and plan to use the latest stable (1.2.x) version). I have tried several different Java libraries, like Hector, Astyanax, Cassandra-jdbc...

Among them, (in short) my choice is Astyanax. But then I also found and tried DataStax's Java Driver, which support new CQL binary protocol, and is much cleaner if you are only using CQL. And it seems version 1.0.0 GA will be released soon.

Which one would you recommend? Thanks.

Halo answered 18/4, 2013 at 18:53 Comment(1)
+1 for Astyanax! awesome api !Upas
S
14

I'd advise you to go with a cql3 based driver. Some choices are the the JDBC driver or even better Datastax's driver which supports asynchronous connections. You might have to build datastax's driver yourself, but this can be done with ease using maven.

Thrift isn't going to be getting any new features in Cassandra, its being kept for backwards comparability and most C* community members advice to use cql based drivers for new projects:

As described above, we believe that CQL3 is a simpler and overall better API for Cassandra than the thrift API is. Therefore, new projects/applications are encouraged to use CQL3

- source

Also CQL's performance is getting better very quickly. Here are some outdated benchmarks.
UPDATE

Since the answer was written a maven central repository was created for the driver so now to use it just add the dependency to maven:

<dependency>
    <groupId>com.datastax.cassandra</groupId>
    <artifactId>cassandra-driver-parent</artifactId>
    <version>1.0.0</version>
</dependency>
Stryker answered 18/4, 2013 at 23:51 Comment(0)
C
9

I have personally used Hector, Astyanax, Pelops, Fluent Cassandra, Datastax's Driver and Pycassa and after using so many API's i finally realized that Astyanax suits me the best (Its my personal consideration).

The feature i found in astyanax which differentiate it from others in the league are

  • Ease of use of the API
  • Composite column support
  • Connection pooling
  • Latency
  • Documentation
  • Updated
Conformation answered 19/4, 2013 at 6:33 Comment(4)
Hector and datastax's driver support composite columns (not sure about the others), and I'd say that CQL is easier to use than Astyanax. Also thrift is on it's way out so CQL3 should be used for new projects.Stryker
well i know mate, actually my consideration was on ease of access. Yes CQL is always been an easier option and will remain so(well known fact RDBMS background) and i can assure that, even max percentage of Astyanax users use CQL statements from their API.Conformation
+1 for Astyanax. CQL is not easier - it only seams to be: you can simply write unperformed queries and run into trouble, because it makes you thing as it would be relational db and does not force you to really understand semantics of nosql store.Chainplate
@MaciejMiklas have you tried the binary driver? You can build queries in 4 lines.Tee
Z
6

I have used Astyanax. It is well documented and easy to use provided you have no problem writing 5 times more code than CQL.

Right now I am using CQL as people I've worked with haven't fully grasped the Astyanax code - why they have to write class for column names. I think you will never understand the internals of Cassandra properly if you don't use Astyanax or Hector.

Zipnick answered 21/5, 2013 at 18:54 Comment(0)
C
4

You should definitely go with the new DataStax Java Driver and Cassandra 1.2 for a new project that is just starting. The driver just went GA, and both the driver and Cassandra 1.2 will only get more stable over the next few months as you develop your new project.

Cousin answered 24/5, 2013 at 20:34 Comment(0)
P
1

I agree with Zanson/Valchkou. DataStax Java Driver is the future. It's very convenient to operate Cassandra with SQL. Meanwhile, I also recommend CassandraExecutor, a simple wrapper of DataStax Java Driver. Comparing to the Java Driver, CassandraExecutor has below features:

  • Consistent/Integrated/Concise APIs for (sync/Async) operations(CRUD) with SQL/entity.
  • DataSet, which supports distinct/merge/sort/groupBy/join/union/unionAll/except/intersect/paginate/filter/count/toJOSN/toXML/toCVS...

Here is a simple CRUD(create/read/update/delete) sample:

Account account = createAccount();
// create
String sql_insert = NE.insert(ID, GUI, FIRST_NAME, LAST_NAME, LAST_UPDATE_TIME, CREATE_TIME).into(Account.class).sql();
cassandraExecutor.execute(sql_insert, account);

// read
String sql_selectByGUI = NE.select(ID, GUI, FIRST_NAME, LAST_NAME).from(Account._).where(L.eq(ID, L.QME)).sql();
Account dbAccount = cassandraExecutor.queryForEntity(Account.class, sql_selectByGUI, account);

// update
String sql_updateByLastName = NE.update(Account.class).set(FIRST_NAME).where(L.eq(ID, L.QME)).sql();

dbAccount.setFirstName("newFirstName");
cassandraExecutor.execute(sql_updateByLastName, dbAccount);

// delete
String sql_deleteByFirstName = NE.deleteFrom(Account.class).where(L.eq(ID, L.QME)).sql();
cassandraExecutor.execute(sql_deleteByFirstName, dbAccount);

(Declaration:I'm the developer of CassandraExecutor)

Pennsylvania answered 22/12, 2015 at 7:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.