通过scala连接cassandra集群 [英] Connecting cassandra cluster through scala

查看:256
本文介绍了通过scala连接cassandra集群的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是scala和cassandra的新人。我知道cassandra与java使用hector的连接。但我不知道如何通过scala连接cassandra。我想要一个简单的例子。

I am new in both scala and cassandra . I know the connectivity of cassandra with java using hector . But I don't know how to connect cassandra through scala. I want a simple example for this.

推荐答案

有一些Scala项目支持Cassandra连接,包括 cassie ,但他们都似乎死了。

There were some Scala projects that arose to support Cassandra connectivity, including cassie by Twitter, but they all seemed to die off.

因为你知道Hector,如果你的类路径中有Hector jar,你可以简单地在Scala中使用Hector API。

Since you know Hector, if you have the Hector jars in your classpath, you can simply use the Hector API in Scala if you prefer.

例如,从< a href =http://hector-client.github.io/hector/build/html/content/getting_started.html#accessing-data =nofollow>文档,您可以执行以下操作:

For example, borrowing from the documentation, you could just do this:

val myCluster = HFactory.getOrCreateCluster("test-cluster","localhost:9160")

val template = new ThriftColumnFamilyTemplate[String, String](ksp, columnFamily, StringSerializer.get(), StringSerializer.get())

我写这个手写,所以语法可能关闭,但你得到的想法。

I wrote this freehand, so the syntax might be off, but you get the idea.

这篇关于通过scala连接cassandra集群的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆