title: Spark Maximum temperature example by definitive guide
body: <p>I am new to scala and I tried to execute the program max temperature from Hadoop definitive guide but it is throwing error array out of bound exception in last. And I am not able to understand clearly the code which is in the book.</p>
  
  <p>Below is the code</p>
  
  <pre><code>import org.apache.spark.SparkContext._
  import org.apache.spark.{SparkConf, SparkContext}
  object MaxTemperature {
  def main(args: Array[String]) {
  val conf = new SparkConf().setAppName("Max Temperature").setMaster("local")
  val sc = new SparkContext(conf)
  val lines = sc.textFile("011990-99999-1949.txt")
  val records = lines.map(_.split("\t"))
  val filtered = records.filter(rec =&gt; (rec(1) != "9999"
  &amp;&amp; rec(2).matches("[01459]")))
  val tuples = filtered.map(rec =&gt; (rec(0).toInt, rec(1).toInt))
  val maxTemps = tuples.reduceByKey((a, b) =&gt; Math.max(a, b))
  maxTemps.foreach(println(_))
  }
  }
  </code></pre>
  
  <p>I am getting the point only that they are reading the file and after that split and map function I am not getting tried to break down the split and map function to different RDD but not got useful things can anyone suggest me how to check the output for each steps.</p>
  
  <p>Thanks &amp; Regards
  Amit</p>