Skip to content

Instantly share code, notes, and snippets.

@niektemme
Created July 31, 2015 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niektemme/cfaa9a5503bce994b251 to your computer and use it in GitHub Desktop.
Save niektemme/cfaa9a5503bce994b251 to your computer and use it in GitHub Desktop.
Smart Thermostat AWS Spark - part Spark score 2
val testval = (valsettemp*10) //temperature to be reached
var tempReached : Long = 70L*60L
val valFirstTempR = valRows.filter(r => r._2 >= testval)
valFirstTempR.cache()
val valFirstTempRhap : Long = valFirstTempR.count()
println("numonovermax")
println(valFirstTempRhap)
if (valFirstTempRhap > 0L) {
val valFirstTempRval : Long = (valFirstTempR.sortByKey().take(1))(0)._1.toLong
println("reached max")
println(valFirstTempRval)
tempReached = valrevepoch - valFirstTempRval //after how many seconds set temperature was reached
}
val mresultmax : Int = ((valRows.map(item => item.swap).sortByKey(false).take(1))(0))._1.toInt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment