incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Stein <crypt...@gmail.com>
Subject Skeletor => Scala wrapper of Hector for Cassandra
Date Mon, 03 Oct 2011 16:57:50 GMT
Hey folks, I pushed my Scala wrapper of Hector for Cassandra
https://github.com/joestein/skeletor

It not only gets Cassandra hooked into your Scala projects quick and simple
but does so in a functional way.

It is not a new library interface for Cassandra because Hector is a great
library as is.  Instead, Skeletor implements Hector so you always have the
best of breed under the hood for using Cassandra while also leveraging all
of the benefits that Scala offers over Java (ok that was so many buzz words
in one sentence that I just vomited in my mouth a little bit, but it is all
true).

Right now the examples are in the test specs for reading & writing (both
Counter & UTF8 type column families).

Basically it is a DSL:

//for writing
val TestColumnFamily = "FixtureTestSkeletor" \ "TestColumnFamily" //define
your Keyspace \ ColumnFamily
var cv = (TestColumnFamily -> "rowKey" has "columnName" of "columnValue")
//create a column value for a row for this column family
var rows:Rows = Rows(cv) //add the row to the rows object
rows add  (TestColumnFamily -> "rowKey" has "anotherColumnName" of
"anotherColumnValue") //and add another row
Cassandra << rows //takes care of all the batch mutate for ya

//and for reading
def processRow(r:String, c:String, v:String) = {
println("r=" + r + " & c=" + c + " with "+ v) //whatever you want to do
}

def sets(mgsq: MultigetSliceQuery[String, String, String]) {
mgsq.setKeys("columnName") //we want to pull out the row key we just put
into Cassandra
 mgsq.setColumnNames("columnValue") //and just this column
}

TestColumnFamily >> (sets, processRow) //get data out of Cassandra and
process it functionally

I will put more up on the wiki and also post more examples of where/how I
have been using it and will evolve it as I go.

Again, for now, the test specs are the place to start
https://github.com/joestein/skeletor/blob/master/src/test/scala/skeletor/SkeletorSpec.scala

Thanx =) Joestein

/*
Joe Stein
http://www.linkedin.com/in/charmalloc
Twitter: @allthingshadoop <http://www.twitter.com/allthingshadoop>
*/

Mime
View raw message