Connecting cassandra cluster through scala

前端 未结 4 1639
深忆病人
深忆病人 2021-02-11 10:40

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 ex

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-11 11:32

    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:

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

    or

    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.

提交回复
热议问题