Created
December 22, 2019 14:14
-
-
Save deeperunderstanding/3a3ee451a5ade3d790abca4ff649d3a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object WordCount extends MapReduce[String, String, Int, Int] { | |
override def mapper(line: String): Seq[KeyValue[String, Int]] = | |
"""[\w']+""".r.findAllIn(line).map { word => KeyValue(word, 1) }.toVector | |
override def reducer(key: String, values: Seq[Int]): KeyValue[String, Int] = | |
KeyValue(key, values.sum) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment