卡桑德拉与斯卡拉
有人对 cassandra 与 scala 一起使用有建议吗?没有原生的scala-cassandra客户端支持cassandra版本8.0+,所以我必须使用hector,它似乎工作正常但不简洁。您对 hector 有任何尝试、建议或任何包装代码等吗?
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 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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Apache Cassandra 和 Datastax Enterprise 的官方 Scala 驱动程序是 phantom,完全支持 CQL 3.0。
Phantom 是由 Datastax 官方合作伙伴 Outworkers 开发的,明确是为了取代所有其他驱动程序。它正在积极开发和维护,并全面支持所有最新的 Cassandra 功能。
免责声明:我是 phantom 的项目负责人,我的建议可能有偏差。我们在 phantom wiki 上提供了更深入的功能比较。
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 是“Cassandra 的 Scala 客户端”:https://github.com/twitter/cassie。
根据 Twitter 的开发区块,该问题于 2012 年 2 月 9 日首次回答该问题后发布。
https://wiki.apache.org/cassandra/ClientOptions 还列出了我认为更旧的 Cascal比卡西.
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.
你看过模板包中的类吗?它们可能会让你的包装更加简洁。我们在 wiki 上有一个快速操作方法:
https://github.com/rantav/hector/wiki/入门-%285-分钟%29
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
Quill 和 Phantom 是两种流行的客户端驱动程序。他们都在底层使用 Datastax。我使用 play 对简单的 json GET/POST 进行了负载测试分析。您可以在 root/loadtest/phantom|quill/results 下的项目中查看结果的并排比较。
可能会帮助您更好地选择驱动程序。
https://github.com/yleun/cassandra-loadtest
Cassandra 3.10
斯卡拉 2.11.8
幻影2.6.4
鹅毛笔1.2.1
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
简介
正如之前的答案所建议的,Cassandra 的基于 Scala 的客户端是:
但是,它们内部都基于 Datastax Java 驱动程序。
就我个人而言,我都不喜欢它们,Java Driver 感觉更加自然和简单。另一方面,这些库在其之上产生了一些开销,因此在性能方面它们总是较差。
Java 驱动程序 Scala 集成
我发现一些文章 (example) 显示如何将 Java Driver 与 Scala 更好地集成,这看起来并不难。
结果是我自己的库,您可以在 GitHub 上找到:https://github.com/atais/scassandra
它允许在 Scala 中无缝集成
CQL
查询和操作ListenableFuture
,而无需将其映射到scala.Future
。享受 :)
Intro
As previous answers suggested Scala based clients for Cassandra are:
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 theListenableFuture
without mapping it intoscala.Future
.Enjoy :)