开发者

cassandra with scala

开发者 https://www.devze.com 2023-03-13 19:44 出处:网络
Does anyone have advice on using cassandra with scala? There is no native scala-cassandra client supporting cassandra version 8.0+, so I have to use开发者_Go百科 hector, and it seems to work OK but no

Does anyone have advice on using cassandra with scala? There is no native scala-cassandra client supporting cassandra version 8.0+, so I have to use开发者_Go百科 hector, and it seems to work OK but not to be concise. Do you have any attempts, recommendations or any wrapper code,.. etc for hector ?


The official Scala driver for Apache Cassandra and Datastax Enterprise, with full support for CQL 3.0, is phantom.

Phantom was developed at Outworkers, official Datastax partners, explicitly to superseed all other drivers. It's being actively developed and maintained, with full support for all the newest Cassandra features.

Disclaimer: I am the project lead on phantom, and a result may be possibly biased in my recommendation. We offer more in depth feature comparisons on the phantom wiki.


Cassie is "A Scala client for Cassandra": https://github.com/twitter/cassie. According to twitter's dev block it was released on 2012-02-09, after the initial answer to this question.

https://wiki.apache.org/cassandra/ClientOptions also lists Cascal which I think is older than Cassie.


Have you looked at the classes in the template package? They may make your wrapper more concise. We have a quick how-to on the wiki: https://github.com/rantav/hector/wiki/Getting-started-%285-minutes%29


Two popular client-drivers are Quill and Phantom. They both use Datastax underneath. I did a load test profiling of a simple json GET/POST using play for both. You can see the side-by-side comparisons of results in the projects under root/loadtest/phantom|quill/results.

Might help you better to choose a driver.

https://github.com/yleun/cassandra-loadtest

Cassandra 3.10 scala 2.11.8 phantom 2.6.4 quill 1.2.1


Intro

As previous answers suggested Scala based clients for Cassandra are:

  • Quill
  • Phantom

However, they both are internally based on Datastax Java Driver.

Personally, I did not like either of them and Java Driver felt much more natural and simple. On the other hand, those libraries created some overhead on top of it, so performance-wise they are always inferior.

Java Driver Scala Integration

I have found some articles (example) showing how you could integrate Java Driver better with Scala and it did not look hard.

The result is my own library that you can find on GitHub: https://github.com/atais/scassandra

It allows for seamless integration in Scala for both CQL queries and manipulating the ListenableFuture without mapping it into scala.Future.

Enjoy :)

0

精彩评论

暂无评论...
验证码 换一张
取 消