From 174e5ec2766dca81e57ee455219b54a689b41e61 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 21 May 2018 12:09:25 -0700 Subject: WordCount -> WordCountJob Also use the exact file from scalding repo --- scald-mvp/src/main/scala/example/WordCount.scala | 12 ------------ scald-mvp/src/main/scala/example/WordCountJob.scala | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 scald-mvp/src/main/scala/example/WordCount.scala create mode 100644 scald-mvp/src/main/scala/example/WordCountJob.scala (limited to 'scald-mvp/src/main') diff --git a/scald-mvp/src/main/scala/example/WordCount.scala b/scald-mvp/src/main/scala/example/WordCount.scala deleted file mode 100644 index 0de6ae0..0000000 --- a/scald-mvp/src/main/scala/example/WordCount.scala +++ /dev/null @@ -1,12 +0,0 @@ - -package example - -import com.twitter.scalding._ - -class WordCount(args : Args) extends Job(args) { - TypedPipe.from(TextLine(args("input"))) - .flatMap { line => line.split("""\s+""") } - .groupBy { word => word } - .size - .write(TypedTsv(args("output"))) -} diff --git a/scald-mvp/src/main/scala/example/WordCountJob.scala b/scald-mvp/src/main/scala/example/WordCountJob.scala new file mode 100644 index 0000000..83a8dd0 --- /dev/null +++ b/scald-mvp/src/main/scala/example/WordCountJob.scala @@ -0,0 +1,12 @@ +package com.twitter.scalding.examples + +import com.twitter.scalding._ + +class WordCountJob(args: Args) extends Job(args) { + TypedPipe.from(TextLine(args("input"))) + .flatMap { line => line.split("\\s+") } + .map { word => (word, 1L) } + .sumByKey + // The compiler will enforce the type coming out of the sumByKey is the same as the type we have for our sink + .write(TypedTsv[(String, Long)](args("output"))) +} -- cgit v1.2.3