Skip to content

Instantly share code, notes, and snippets.

@GnaneshKunal
Last active September 24, 2017 19:11
Show Gist options
  • Save GnaneshKunal/99c50fec498a2f056213385c6cf1d29e to your computer and use it in GitHub Desktop.
Save GnaneshKunal/99c50fec498a2f056213385c6cf1d29e to your computer and use it in GitHub Desktop.
No Mercy WWE
import org.apache.log4j._
import org.apache.spark._
object noMercy extends App {
Logger.getLogger("org").setLevel(Level.ERROR)
val sc = new SparkContext("local[*]", "No Mercy Prediction")
val noMercyResults = sc.textFile("/home/monster/git/scala-spark/src/main/resources/nomercy.txt")
val parsedI = noMercyResults.map(mapValues)
val last = parsedI.reduceByKey((x: Tuple2[String, Double], y: Tuple2[String, Double]) => if (x._2 < y._2) x else y)
last.foreach(println)
def mapValues(line: String) = {
val fields = line.split(',')
fields(0) -> (fields(1), fields(2).toDouble / (fields(2).toDouble + fields(3).toDouble))
}
}
Universal Champ,Brock Lesnar,1,4
Universal Champ,Braun Strowman,5,2
REvs.JC,Roman Reigns,8,11
REvs.JC,John Cena,1,1
Women's Champ,Alexa Bliss,5,6
Women's Champ,Sasha Banks,7,2
Women's Champ,Bayley,10,3
Women's Champ,Nia Jax,11,4
Women's Champ,Emma,6,1
Tag Team,Seth Rollins & Dean Ambrose,4,9
Tag Team,Cesaro & Sheamus,6,4
FBvs.BW,Finn Bálor,3,10
FBvs.BW,Bray Wyatt,11,5
Intercontinental Champ,The Miz,11,10
Intercontinental Champ,Jason Jordan,4,6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment