aboutsummaryrefslogtreecommitdiffstats
path: root/scald-mvp/src/main/scala/example/WordCount.scala
blob: f7230c1ae0ffa6fa8217a0a7755eccf0824172bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

package example

import com.twitter.scalding._

object WordCountJob {

  def main(args: Array[String]) {
    (new WordCountJob(Args(List("--local", "", "--input", "dummy.txt", "--output", "dummy-out.txt")))).run

    import io.Source
    for (line <- Source.fromFile("dummy-out.txt").getLines())
      println(line)
  }
}

class WordCountJob(args : Args) extends Job(args) {
  TypedPipe.from(TextLine(args("input")))
    .flatMap { line => line.split("""\s+""") }
    .groupBy { word => word }
    .size
    .write(TypedTsv(args("output")))
}