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.
相关问题
- Unusual use of the new keyword
- Get Runtime Type picked by implicit evidence
- What's the point of nonfinal singleton objects
- PlayFramework: how to transform each element of a
- What version of Java does Cassandra 3 require
相关文章
- Gatling拓展插件开发,check(bodyString.saveAs("key"))怎么实现
- RDF libraries for Scala [closed]
- Cassandra Read a negative frame size
- Why is my Dispatching on Actors scaled down in Akk
- How do you run cucumber with Scala 2.11 and sbt 0.
- GRPC: make high-throughput client in Java/Scala
- Setting up multiple test folders in a SBT project
- Testing request with CSRF Token in Play framework
I've been working on Scala wrapper of Java Driver to minimize boilerplate code. You could find it here: https://github.com/InnovaCo/binders-cassandra
Here is an example of class that works with some Cassandra DB:
To use library in your playframework project, add this line to the build.sbt file:
I am using the datastax java driver. It's development is still active on github. I looked at Hector earlier but it seemed dying. The doc here's helpful: http://www.datastax.com/documentation/developer/java-driver/1.0/webhelp/index.html#java-driver/quick_start/qsQuickstart_c.html. I translated the first example to scala. Also, look at the akka-cassandra example from typesafe activator. Cheers.
There were some Scala projects that arose to support Cassandra connectivity, including cassie by Twitter, but they all seemed to die off.
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.
For example, borrowing from the documentation, you could just do this:
or
I wrote this freehand, so the syntax might be off, but you get the idea.