agemooij / riak-scala-client

An easy to use, non-blocking, fast Scala client library for interacting with Riak.
http://riak.scalapenos.com/
Apache License 2.0
84 stars 24 forks source link

Implementation of MapReduce over HTTP #11

Open kender-janrain opened 11 years ago

kender-janrain commented 11 years ago

Hi there! I've put together an implementation of MapReduce that I'd like to submit. The interface is fairly straight forward, here's an example.

implicit val actorSystem = ActorSystem()
val riakClient = RiakClient(actorSystem, "localhost", 8098)

def src(name: String) = Source.fromInputStream(getClass.getClassLoader.getResourceAsStream(name)).mkString

val result = {
    import RiakMapReduce._
    riakClient.mapReduce(InputBucket("bucket"))
        .map(JsBuiltin("Riak.mapValuesJson"))
        .reduce(JsSource(src("reduce1.js")))
        .map(JsSource(src("map2.js")))
        .reduce(JsSource(src("reduce2.js")))
        .result[List[Int]]
}
println(Await.result(result, 10.seconds))

If you like the interface and the methodology of the implementation, I'd be happy to provide specs as well.

agemooij commented 11 years ago

Hi Kender

First of all, thanks you very much for being the first to submit a pull request for riak-scala-client. I'm a bit busy at the moment but I'll have a look at your code as soon as possible, probably this weekend, and get back to you.