推ter 流处理框架:Summingbird

jopen 10年前

Summingbird是一个库,能够让你编写 MapReduce 程序看起来像原生的 Scala 或 Java 集合。并在一些著名的分布式MapReduce平台上转换并执行他们,包括 StormScalding.。

在纯Scala中的一个字数计算聚集可能是这样的:

  def wordCount(source: Iterable[String], store: MutableMap[String, Long]) =      source.flatMap { sentence =>        toWords(sentence).map(_ -> 1L)      }.foreach { case (k, v) => store.update(k, store.get(k) + v) }

在Summingbird计算的话看起来像这样:

  def wordCount[P <: Platform[P]]      (source: Producer[P, String], store: P#Store[String, Long]) =        source.flatMap { sentence =>          toWords(sentence).map(_ -> 1L)        }.sumByKey(store)


 

项目主页:http://www.open-open.com/lib/view/home/1390573543804