带有 Scala 的 cassandra
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6382763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
cassandra with scala
提问by sirmak
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 ?
有人对将 cassandra 与 Scala 一起使用有什么建议吗?没有支持 cassandra 8.0+ 版的原生 scala-cassandra 客户端,所以我必须使用 hector,它似乎工作正常但不够简洁。您对 hector 有任何尝试、建议或任何包装代码等吗?
采纳答案by jkline
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.
Cassie 是“Cassandra 的 Scala 客户端”:https: //github.com/twitter/cassie。根据 twitter 的开发块,它于 2012-02-09 发布,在对这个问题的初步回答之后。
https://wiki.apache.org/cassandra/ClientOptionsalso lists Cascal which I think is older than Cassie.
https://wiki.apache.org/cassandra/ClientOptions还列出了我认为比 Cassie 更老的 Cascal。
回答by flavian
The official Scala driver for Apache Cassandra and Datastax Enterprise, with full support for CQL 3.0, is phantom.
Apache Cassandra 和 Datastax Enterprise 的官方 Scala 驱动程序,完全支持 CQL 3.0,是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.
Phantom 是在官方 Datastax 合作伙伴 Outworkers 开发的,旨在取代所有其他驱动程序。它正在积极开发和维护,完全支持所有最新的 Cassandra 功能。
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.
免责声明:我是 phantom 的项目负责人,结果可能会在我的推荐中有所偏差。我们在 phantom wiki 上提供了更深入的功能比较。
回答by zznate
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
你看过模板包中的类了吗?它们可能会使您的包装器更加简洁。我们在 wiki 上有一个快速的操作方法:https: //github.com/rantav/hector/wiki/Getting-started-%285-minutes%29
回答by YP Leung
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.
两个流行的客户端驱动程序是 Quill 和 Phantom。他们都在下面使用 Datastax。我使用 play 对简单的 json GET/POST 进行了负载测试分析。可以在 root/loadtest/phantom|quill/results 下的项目中看到结果的并排比较。
Might help you better to choose a driver.
可能会帮助您更好地选择驱动程序。
https://github.com/yleun/cassandra-loadtest
https://github.com/yleun/cassandra-loadtest
Cassandra 3.10 scala 2.11.8 phantom 2.6.4 quill 1.2.1
卡桑德拉 3.10 斯卡拉 2.11.8 幻影 2.6.4 羽毛笔 1.2.1
回答by Atais
Intro
介绍
As previous answers suggested Scala based clients for Cassandra are:
正如之前的答案所建议的,Cassandra 的基于 Scala 的客户端是:
However, they both are internally based on Datastax Java Driver.
但是,它们都在内部基于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 感觉更自然和简单。另一方面,这些库在其上产生了一些开销,因此在性能方面它们总是较差。
Java Driver Scala Integration
Java 驱动程序 Scala 集成
I have found some articles (example)showing how you could integrate Java Driver better with Scala and it did not look hard.
我发现一些文章(示例)展示了如何将 Java Driver 与 Scala 更好地集成,看起来并不难。
The result is my own library that you can find on GitHub: https://github.com/atais/scassandra
结果是我自己的库,你可以在 GitHub 上找到:https: //github.com/atais/scassandra
It allows for seamless integration in Scala for both CQLqueries and manipulating the ListenableFuturewithout mapping it into scala.Future.
它允许在 Scala 中无缝集成CQL查询和操作ListenableFuture而不将其映射到scala.Future.
Enjoy :)
享受 :)

